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 statistic results. 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:-The number of bytes in the C statistic. -L COUNT the number of rows. -M counts the number of characters. This flag cannot be associated with-The c flag is used together. -WCount 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 information--version displays release information4. Usage Example: Instance 1: View the number of bytes, words, and lines of a file command:WCtest.txt output: [[email protected] test]#Cattest.txt hnlinuxpeida.cnblogs.comubuntuubuntu linuxredhatredhatlinuxmint[[email protected] test]#WCTest.txt7 8 -Test.txt[[email protected] test]#WC-l Test.txt7Test.txt[[email protected] test]#WC-C Test.txt -Test.txt[[email protected] test]#WC-WTest.txt8Test.txt[[email protected] test]#WC-m Test.txt -Test.txt[[email protected] test]#WC-L test.txt -test.txt Description:7 8 -test.txt number of words in a row number of bytes file name Instance 2: How to do with WC command Print statistics not print file name command: output: [email protected] test]#WC-l Test.txt7Test.txt[[email protected] test]#CatTest.txt |WC-L7[[email protected] test] #说明: Use pipe lines, which is especially useful when writing shell scripts. Example 3: Used to count the number of files in the current directory command:ls-L |WC-l Output: [[email protected] test]# CD Test6[[email protected] test6]# ll Total604---xr--r--1Root Mail302108 One- - ,: theLinklog.log---xr--r--1Mail users302108 One- - ,: theLog2012.log-rw-r--r--1Mail users A One- - ,: theLog2013.log-rw-r--r--1Root Mail0 One- - ,: theLog2014.log-rw-r--r--1Root Mail0 One- - ,: theLog2015.log-rw-r--r--1Root Mail0 One- - ,: theLog2016.log-rw-r--r--1Root Mail0 One- - ,: theLog2017.log[[email protected] test6]#ls-L |WC-L8[[email protected] TEST6] #说明: The number contains the current directory
Linux Command Learning Note (max): WC command