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.
1. Command format:
WC [Options] File ...
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:
-C Count bytes.
-L counts the number of rows.
-M counts the number of characters. This flag cannot be used with the-C flag.
-W count words. A word is defined as a string separated by a blank, a jump, or a newline character.
-L Prints the length of the longest line.
-HELP Display Help information
--version displaying version information
Common ways:
1. Count the number of files in a directory
Ls-l|wc-l
2. Count the number of rows of a file
Cat Test.txt |wc-l
3. Count the number of words in a file
Cat Test.txt |wc-l
4. Count the number of executable files in a directory
Ls-f | grep *$|wc-l
the executable * number, add a / number to the directory , add an @ to the symbolic link
Example: This directory contains only subdirectories, which are displayed after each directory/
5. Count the number of directories in a directory
Ls-l|grep "^d" |wc-l
LINUX--WC command