1. Command function
wc count lines, words and bytes of a file
2. Grammar format
wc option file
wc option --files0-from=F
Parameter Description
parameter |
Parameter Description |
-c |
Statistics bytes |
-m |
count characters |
-l |
count rows |
-w |
count words |
-L |
print the length of the longest line |
3. Example of use
Example 1 View the number of bytes, words, and lines of the passwd file.
[root@localhost ~]# wc /etc/passwd #No parameters 25 33 1076 /etc/passwd #25 means the number of lines; 33 means the number of words; 1076 means the number of bytes [root@localhost ~]# wc -c /etc/passwd #Statistical bytes 1076 /etc/passwd [root@localhost ~]# wc -m /etc/passwd #Count characters 1076 /etc/passwd [root@localhost ~]# wc -w /etc/passwd #Count the number of words 33 /etc/passwd [root@localhost ~]# wc -l /etc/passwd #Count the number of lines 25 /etc/passwd [root@localhost ~]# wc -L /etc/passwd #Count the length of the longest line 66 /etc/passwd
Example 2 Checking the number of users logged in to the system
[root@localhost ~]# who root pts/0 2018-04-24 14:23 (172.16.2.100) root pts/1 2018-04-24 15:15 (172.16.2.100) root pts/2 2018-04-24 14:32 (172.16.2.100) root pts/3 2018-04-24 15:19 (172.16.2.100) [root@localhost ~]# who |wc -l 4