The use of Linux in the wc command

Linux system function in wc (Word Count) command is byte counts in the specified file, words, lines, and statistics showed that output.

1. Format:

wc [options] [file 1] [File 2] ...

2. Function:

Byte counts in the specified file, words, lines, and the statistical result display output. This command specifies the number of bytes of the file, words, lines. If no file is given, read from standard input. wc also gives the president the specified file count.

3. Command parameters:

 

- c byte counts.
- L count the number of rows.
-m character counts. This flag can not be - used with the c flag.
- w word count. A word is defined as spaces, tabs, or changing the character strings separated by rows.
- L printing length of the longest line.
- Help displays help information
 --version Show version information

Example 4

testfile testfile_1 testfile_2 WC    # statistics three files 

# output 
3 92 598 testfile                     # first file number of rows is 3, the number of words 92, the number of bytes 598   
9 78 18 is testfile_1                    # number of lines to the second file 9 , words 18, the number of bytes 78   
3 6 32 testfile_2                     # rows third file is 3, the number of words 6, 32 bytes   
total amount 15116708                     # three lines in total number of files is 15, the number of words 116, the number of bytes 708

In fact personally I think that the most commonly used parameters or -l, which is used to count the number of standard output file or rows, in fact, can be used to do a lot of statistics about everything.

For example, the number of ordinary files in the current directory statistics:

$ ls -l
total 4
-rw-rw-r-- 1 hyb hyb  0 3月  21 20:32 test2.txt
-rw-rw-r-- 1 hyb hyb 13 3月  21 20:18 test.txt
$ ls -l |grep "^-"|wc -l
2

You can get the number of files is 2. grep "^ -" mean, what for - the beginning of the line, because ordinary documents are in order - beginning.

 

Linux system function in wc (Word Count) command is byte counts in the specified file, words, lines, and statistics showed that output.

1. Format:

wc [options] [file 1] [File 2] ...

2. Function:

Byte counts in the specified file, words, lines, and the statistical result display output. This command specifies the number of bytes of the file, words, lines. If no file is given, read from standard input. wc also gives the president the specified file count.

3. Command parameters:

 

- c byte counts.
- L count the number of rows.
-m character counts. This flag can not be - used with the c flag.
- w word count. A word is defined as spaces, tabs, or changing the character strings separated by rows.
- L printing length of the longest line.
- Help displays help information
 --version Show version information

Example 4

testfile testfile_1 testfile_2 WC    # statistics three files 

# output 
3 92 598 testfile                     # first file number of rows is 3, the number of words 92, the number of bytes 598   
9 78 18 is testfile_1                    # number of lines to the second file 9 , words 18, the number of bytes 78   
3 6 32 testfile_2                     # rows third file is 3, the number of words 6, 32 bytes   
total amount 15116708                     # three lines in total number of files is 15, the number of words 116, the number of bytes 708

In fact personally I think that the most commonly used parameters or -l, which is used to count the number of standard output file or rows, in fact, can be used to do a lot of statistics about everything.

For example, the number of ordinary files in the current directory statistics:

$ ls -l
total 4
-rw-rw-r-- 1 hyb hyb  0 3月  21 20:32 test2.txt
-rw-rw-r-- 1 hyb hyb 13 3月  21 20:18 test.txt
$ ls -l |grep "^-"|wc -l
2

You can get the number of files is 2. grep "^ -" mean, what for - the beginning of the line, because ordinary documents are in order - beginning.

 

Guess you like

Origin www.cnblogs.com/yoyowin/p/12095522.html