wc --help

  1. 用法:wc [选项]... [文件]...

  2.  或:wc [选项]... --files0-from=F

  3. 输出每个指定文件的行数、单词计数和字节数,如果指定了

  4. 多于一个文件,继续给出所有相关数据的总计。如果没有指定

  5. 文件,或者文件为"-",则从标准输入读取数据。

  6. -c, --bytes 输出字节数统计

  7. -m, --chars 输出字符数统计

  8. -l, --lines 输出行数统计

  9. --files0-from=文件 从指定文件读取以NUL 终止的名称,如果该文件被

  10. 指定为"-"则从标准输入读文件名

  11. -L, --max-line-length 显示最长行的长度

  12. -w, --words 显示单词计数

  13. --help 显示此帮助信息并退出

  14. --version 显示版本信息并退出

  15.  
  16. 请向bug-coreutils@gnu.org 报告wc 的错误

  17. GNU coreutils 项目主页:<http://www.gnu.org/software/coreutils/>

  18. GNU 软件一般性帮助:<http://www.gnu.org/gethelp/>

  19. 请向<http://translationproject.org/team/zh_CN.html> 报告wc 的翻译错误

  20. 要获取完整文档,请运行:info coreutils 'wc invocation'


使用实例

 

实例1:查看文件的字节数、字数、行数

[root@localhost test]# cat test.txt 

hnlinux

peida.cnblogs.com

ubuntu

ubuntu linux

redhat

Redhat

linuxmint

[root@localhost test]# wc test.txt

 7  8 70 test.txt

[root@localhost test]# wc -l test.txt 

7 test.txt

[root@localhost test]# wc -c test.txt 

70 test.txt

[root@localhost test]# wc -w test.txt 

8 test.txt

[root@localhost test]# wc -m test.txt 

70 test.txt

[root@localhost test]# wc -L test.txt 

17 test.txt

 

说明:

7     8     70     test.txt

行数 单词数 字节数 文件名

 

 

实例2:用wc命令怎么做到只打印统计数字不打印文件名

[root@localhost test]# wc -l test.txt 

7 test.txt

[root@localhost test]# cat test.txt |wc -l

7[root@localhost test]#

说明:使用管道线,这在编写shell脚本时特别有用。

 

 

实例3:用来统计当前目录下的文件数

[root@localhost test]# cd test6

[root@localhost test6]# ll

总计 604

---xr--r-- 1 root mail  302108 11-30 08:39 linklog.log

---xr--r-- 1 mail users 302108 11-30 08:39 log2012.log

-rw-r--r-- 1 mail users     61 11-30 08:39 log2013.log

-rw-r--r-- 1 root mail       0 11-30 08:39 log2014.log

-rw-r--r-- 1 root mail       0 11-30 08:39 log2015.log

-rw-r--r-- 1 root mail       0 11-30 08:39 log2016.log

-rw-r--r-- 1 root mail       0 11-30 08:39 log2017.log

[root@localhost test6]# ls -l | wc -l

8

[root@localhost test6]#

说明:数量中包含当前目录


实例部分,转自:http://www.cnblogs.com/peida/archive/2012/12/18/2822758.html

GitHub 加速计划 / li / linux-dash
10
2
下载
A beautiful web dashboard for Linux
最近提交(Master分支:18 天前 )
186a802e added ecosystem file for PM2 5 年前
5def40a3 Add host customization support for the NodeJS version 5 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐