为什么由这个小短文
在kernel 顶层Makefile中有如下代码,这部分代码是用于生成UTS_RELEASE的。其中UTS长度通过wc -c命令来检查。
1168 uts_len := 64
1169 define filechk_utsrelease.h
1170 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
1171 echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
1172 exit 1; \
1173 fi; \
1174 echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"
1175 endef
1. wc命令含义
qemu@qemu:~/linux-5.4.124$ wc --help
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: <http://www.gnu.org/software/coreutils/>
Full documentation at: <http://www.gnu.org/software/coreutils/wc>
or available locally via: info '(coreutils) wc invocation'
qemu@qemu:~/linux-5.4.124$
2. wc使用
- 统计文件包含的字符个数
注意,统计字符个数是包含空格的。
qemu@qemu:~$ cat wc.txt | wc -c
12
qemu@qemu:~$ ll wc.txt
-rw-rw-r-- 1 qemu qemu 12 9月 17 18:55 wc.txt
qemu@qemu:~$
- 统计文件word数
统计word个数的时候是以空格为划分的
qemu@qemu:~$ cat wc.txt | wc -w
4
qemu@qemu:~$ cat wc.txt
aa bb cc dd
- 统计文件行数
qemu@qemu:~$ cat wc.txt |wc -l
1
qemu@qemu:~$
qemu@qemu:~$ cat wc.txt
aa bb cc dd
qemu@qemu:~$
- 统计最大显示宽度
qemu@qemu:~$ cat wc.txt |wc -L
11
qemu@qemu:~$
qemu@qemu:~$ cat wc.txt
aa bb cc dd
qemu@qemu:~$