Home > Article > Operation and Maintenance > How to use Linux wc command
Linux wc command is used to count word count.
Using the wc command, we can calculate the number of Bytes, words, or columns of a file. If the file name is not specified, or the file name is given as "-", the wc command will read the file from the standard input device. Read data.
Syntax:
wc
Parameters:
-c or --bytes or --chars Only the number of Bytes is displayed.
-l or --lines displays the number of lines.
-w or --words displays only the number of words.
--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
First check the content 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.
Use wc statistics, the results are as follows:
$ wc testfile # testfile文件的统计信息 3 92 598
Among them, the 3 numbers are respectively Indicates the number of lines, words, and bytes of the testfile file.
If you want to count the information of multiple files at the same time, such as testfile, testfile_1, and testfile_2 at the same time, you can use the following command:
wc
The output result is as follows:
$ wc testfile testfile_1 testfile_2 #统计三个文件的信息 3 92 598 testfile #第一个文件行数为3、单词数92、字节数598 9 18 78 testfile_1 #第二个文件的行数为9、单词数18、字节数78 3 6 32 testfile_2 #第三个文件的行数为3、单词数6、字节数32 15 116 708
The above is the detailed content of How to use Linux wc command. For more information, please follow other related articles on the PHP Chinese website!