Linux wc命令
更多资料下载,冲击月薪过万,一线经验工程师录制,
干货满满的嵌入式视频教程,请点击淘宝店:wanglitao.taobao.com
Linux wc命令用来统计一个文件中的行数、字数、字节数。
wc [参数] [文件名]
wc命令常用参数:
参数 | 参数说明 |
---|---|
-w | 统计字数:由空白、tab或换行字符分隔的字符串个数 |
-c | 统计字节数,单位为Byte |
-l | 统计行数 |
-m | 统计字符数 |
-L | 打印最长行的长度 |
使用示例:
统计源文件hello.c中的代码行数:
# cat hello.c -n
1 #include <stdio.h>
2
3 int main(void)
4 {
5 printf("hello world!\n");
6 return 0;
7 }
8
# wc -l hello.c
8 hello.c
统计hello.c中,最长一行代码的长度:
# wc -L hello.c
29 hello.c
统计hello.c中的字节数:
# ls -l
-rw-r--r-- 1 root root 84 Feb 13 17:33 hello.c
# wc -c hello.c
84 hello.c
《Linux三剑客》视频教程,从零开始快速掌握Linux开发常用的工具:Git、Makefile、vim、autotools、debug,免费赠送C语言视频教程,C语言项目实战:学生成绩管理系统。详情请点击淘宝链接:Linux三剑客