The function of the WC (Word Count) command in a Linux system is to count the number of bytes, words, and lines in the specified file, and to display the output of the statistic results.
Original: http://blog.jobbole.com/109925/
http://blog.csdn.net/jerry_1126/article/details/52107947------Diagram
1. Command format:
2. Command function:
Counts the number of bytes, words, and lines in the specified file, and displays the output of the statistics. This command counts the number of bytes, word count, and number of lines in the specified file. If the file name is not given, it is read from the standard input. The WC also gives the president count of the files specified.
3. Command parameters:
Shell
12345678910111213 |
-C count bytes. -L COUNT the number of rows. -m counts the number of characters. This flag cannot be used with the-C flag. -W counts the number of words. A word is defined as a string separated by a blank, a jump, or a newline character. -L Print the length of the longest line. -help Display assistance - -version displays release information |
4. Usage examples:
Example 1: View the number of bytes, words, and lines of a file
Command:
Shell
Output:
Shell
123456789101112131415161718192021222324252627282930313233343536373839 |
[root@localhost test]# cat test.txt HnlinuxPeida. cnblogs. com Ubuntuubuntu Linux RedhatRedhatLinuxMint[root@localhost test]# WC test.txt 7 8 test.txt [root@localhost test]# wc-l test.txt 7 test.txt [root@localhost test]# wc-c test.txt test.txt [root@localhost test]# wc-w test.txt 8 test.txt [root@localhost test]# wc-m test.txt test.txt [root@localhost test]# wc-l test.txt test.txt |
Description
Shell
123 |
7 8 test.txt number of lines Word count bytes file name |
Example 2: How to do a WC command to print only statistics do not print file names
Command:
Output:
Shell
1 |
[root@localhost test]# wc-l test.txt |
7 Test.txt
Shell
123 |
[root@localhost test]# cat test.txt |wc-l 7[root@localhost test]# |
Description
Using pipe lines, which is especially useful when writing shell scripts.
Example 3: Used to count the number of files in the current directory
Command:
Shell
Output:
Shell
12345678910111213141516171819202122232425 |
[root@localhost test]# cd Test6 [root@localhost test6]# ll Total604--- XR--R-- 1 root mail 302108 - : linklog. Log --- XR--R-- 1 mail users 302108 - :39 log2012. Log -RW-R--R-- 1 mail users -- £ º log2013 . Log -RW-R--R-- 1 root mail 0 -from : log2014 . Log -RW-R--R-- 1 root mail 0 -from : log2015 . Log -RW-R--R-- 1 root mail 0 -from : log2016 . Log -RW-R--R-- 1 root mail 0 -from : log2017 . Log [root@localhost test6]# ls-l | wc-l 8[root@localhost test6]# |
Description
The number contains the current directory
Go Linux command (max): WC command