This original article belongs to "Linux greenhouse" blog, the blog address is http://roclinux.cn. The author of the article is rocrocket.
In order to prevent the vicious reproduction of some websites, special in each article before adding this information, but also hope that readers understand.
===
[Start of body]
Today's content is the WC command of Linux, this name is very well remembered, because what, you also know.
The function of this command is also very well remembered, because it has limited functionality:
Wc-c FileName: Shows the number of bytes in a file
WC-M FileName: Displays the number of characters in a file
Wc-l FileName: Displays the number of rows for a file
Wc-l FileName: Displays the length of the longest line in a file
WC-W FileName: Displays the number of words in a file
[Rocrocket@rocrocket programming]$Cat Wc1.txt12345 Hello[Rocrocket@rocrocket programming]$Wc-C Wc1.txtWc1.txt[Rocrocket@rocrocket programming]$Wc-M Wc1.txtWc1.txt[Rocrocket @rocrocket programming ]$ wc -l wc1.txt3 wc1.txt[rocrocket< Span style= "color: #000000; Font-weight:bold; " > @rocrocket programming]$ WC -l wc1.txt4 wc1.txt[rocrocket @rocrocket programming]$ wc -w wc1.txt5 wc1.txt |
Line breaks at the end of each line are also counted as one character, and a space is counted as a character.
Because of the UTF-8 encoding, a Chinese character is converted here to 3 bytes, so wc-c displays a result of 16, which is "4 bytes of the first row + 5 bytes of the second row + 7 bytes for the third row" =4+5+7=16.
When using the-M option, a Chinese character is calculated as a character, so it is 4+5+3=12.
When using-l, the length of the longest line is given, the second line is the longest, and is 4 characters long. (It is obvious that the newline character is not counted).
Using-W is to calculate the word count, a word is a word, so "34" represents a word, and a "hello" represents a word, so 2+2+1=5.
Jack said tab tab, this symbol is very special, when using-l, the tab count is 7 characters (this depends on the length of a tab, in my System a tab count 7 space length,). When you use-W, the tabs and spaces are not the same, and are treated as a word interval. When using-C, a tab is also a character ( I think it should write bytes instead of characters,-C is the number of bytes ), because it is really just a character.
If you execute the WC wc1.txt directly, the display:
[Rocrocket@rocrocket programmingWC wc1.txtwc1.txt |
The output information is, in turn, the number of rows in bytes file name.
"WC"-linux command five-minute series 17