Linux命令篇-wc 命令

wc – print newline, word, and byte counts for each file

wc: 统计文件的 字节数字数行数

格式: wc [OPTION]… [FILE]…

常用参数:

OPTION 意义 -w 统计字数,或–words:只显示字数。一个字被定义为由空白、跳格或换行字符分隔的字符串 -c 统计字节数,或–bytes或–chars:只显示Bytes数 -l 统计行数,或–lines:只显示列数 -m 统计字符数 -L 打印最长行的长度 –help 显示帮助信息 –version 显示版本信息

参考示例:

  • 统计字数
创建 test.out 文件
$ vi test.out
hello world
hello world
hello world
hello world hello world

查看 test.out 文件
$ cat test.out
hello world
hello world
hello world
hello world hello world
$ wc -w test.out
10 test.txt
  • 统计字节数
$ wc -c test.out
60 test.txt
  • 统计字符数
$ wc -m test.out
60 test.txt
  • 统计单词数
$ wc -w test.out
10 test.out
  • 统计 行数单词数字节数
$ wc test.out   //等价于 wc -lwc test.out
4 10 60 test.out
  • 统计行数
$ wc -l test.out
4 test.out
  • 打印最长行的长度
$ wc -L test.out
23 test.out

Original: https://www.cnblogs.com/HOsystem/p/16737353.html
Author: HOsystem
Title: Linux命令篇-wc 命令

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/606786/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球