1. Man手册
WC(1) User Commands WC(1)
NAME
wc - print newline, word, and byte counts for each file
SYNOPSIS
wc [OPTION]… [FILE]…
wc [OPTION]… —files0-from=F
DESCRIPTION
Print newline, word, and byte counts for each FILE, and a total line if more than one FILE is
specified. With no FILE, or when FILE is -, read standard input. A word is a non-zero-length
sequence of characters delimited by white space. 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 length of the longest line
-w, —words
print the word counts
—help display this help and exit
—version
output version information and exit
2. 命令常用选项方式及组合
2.1 基本组合
wc file
# wc input.txt
4 7 40 input.txt
4 - lines
7 - words
40 - characters equavilent to '-m'
wc -c/-m/-l/-w file
- wc -L
2.2 多个输入file
# wc input.txt input.txt
4 7 40 input.txt
4 7 40 input.txt
8 14 80 total
2.3 从文件或stdin中读取多个文件名选项 —files0-from=F
--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.
--files0-from=F
选项需要依赖 NUL
字符帮助识别,无论输入是file F还是stdin.
NUL
字符的输出方式:
Ctrl+V
+Ctrl+Shift+@
StackOverflow上输出 NUL
的方式有具体解答,以及在StackOverflow上的这个问题地址及解答.
- find 命令的 -print0 选项
实际使用方式展示
# way1
echo "abc def" > input1.txt
echo "ghi jkl" > input2.txt
find . -name "input*.txt" -print0 > name.txt
wc --files0-from=name.txt
1 2 8 ./input1.txt
1 2 8 ./input2.txt
2 4 16 total
# way2
wc --files0-from=-
input1.txt^@input2.txt^@
1 2 8 input1.txt
1 2 8 input2.txt