The Linux wc command is used to count the number of lines, characters, and bytes of a file

15941573:

The Linux wc command is used to count words.

We can use the wc command to calculate the number of bytes, words, or columns of the file. If the file name is not specified, or the given file name is "-", the wc command will read data from the standard input device.

Syntax
wc [-clw] [–help] [–version] [file…]
Parameters:

-c or --bytes or --chars only display the number of Bytes.
-l or –lines display the number of lines.
-w or --words only display word count.
--help Online help.
–version Display version information.
Example
By default, wc will calculate the number of lines, words, and bytes of the specified file. The command used is:

wc testfile 

First look at the contents of the testfile file, you can see:

cat testfile  

Linux networks are becoming more and more common, but scurity is often an overlooked
issue. Unfortunately, in today’s environment all networks are potential hacker targets,
fro0m tp-secret military research networks to small home LANs.
Linux Network Securty focuses on securing Linux in a networked environment, where the
security of the entire network needs to be considered rather than just isolated machines.
It uses a mix of theory and practicl techniques to teach administrators how to install and
use security applications, as well as how the applcations work and why they are necesary.
使用 wc统计,结果如下:

wc testfile           # testfile文件的统计信息  

3 92 598 testfile # The number of lines of the testfile is 3, the number of words is 92, and the number of bytes is 598.
Among them, the three numbers represent the number of lines, the number of words, and the number of bytes of the testfile respectively.

If you want to count the information of multiple files at the same time, for example, testfile, testfile_1, and testfile_2 at the same time, you can use the following command:

wc testfile testfile_1 testfile_2   #统计三个文件的信息 

The output is as follows:

$ wc testfile testfile_1 testfile_2 #Statistic information of three files
3 92 598 testfile #The number of lines in the first file is 3, the number of words is 92, the number of bytes is 598
9 18 78 testfile_1 #The number of lines in the second file is 9, words Number 18, number of bytes 78
3 6 32 testfile_2 #The number of lines of the third file is 3, the number of words is 6, the number of bytes is 32
15 116 708 total usage #The total number of lines of the three files is 15, the number of words is 116, Bytes 708

Guess you like

Origin blog.csdn.net/qq_15821487/article/details/131953660