关注公众号 “融码一生”,领取全套 PDF / 电子书
- wc 命令:对文本进行统计,包括单词个数、行数、字节数
-
wc [选项] [文件名]
-
-
- 选项:
-
-
-
-
-c
:统计字节数-w
:统计单词数-l
:统计行数
-
-
[test1@VM-4-13-centos ~]$ wc -l <test.sh
:<<!
5
!
1、常用命令
(1)统计文件中的单词数
- 英文文件(统计 word 数)
-
wc -w file_name
- 中文文件(统计字符数;统计时换行符也会被统计进去)
-
wc -m file_name
(2)统计文件行数
wc -l file_name
2、参数解析
Usage: wc [OPTION]... [FILE]...
or: wc [OPTION]... --files0-from=F
Print newline, word, and byte counts for each FILE, and a total line if
more than one FILE is specified. A word is a non-zero-length sequence of
characters delimited by white space.
With no FILE, or when FILE is -, read standard input.
The options below may be used to select which counts are printed, always in
the following order: newline, word, character, byte, maximum line length.
-c, --bytes print the byte counts
-m, --chars print the character counts
-l, --lines print the newline counts
--files0-from=F read input from the files specified by
NUL-terminated names in file F;
If F is - then read names from standard input
-L, --max-line-length print the maximum display width
-w, --words print the word counts
--help display this help and exit
--version output version information and exit
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Full documentation at: <https://www.gnu.org/software/coreutils/wc>
or available locally via: info '(coreutils) wc invocation'
关注公众号 “融码一生”,领取全套 PDF / 电子书