English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Linux wc command is used to calculate word count.
Using the wc command, we can calculate the number of bytes, words, or columns in a file. If no file name is specified, or the given file name is "-If the parameter ", then the wc command will read data from the standard input device.
wc [-clw][--help][--version][file...]
Parameter:
-c or--bytes or--chars Only display Bytes count.
-l or--lines Display line count.
-w or--words Only display word count.
--help Online help.
--version Show version information.
By default, wc calculates the number of lines, words, and bytes of the specified file. The command used is:
wc testfile
First, check the content of the testfile, and you can see:
$ cat testfile Linux networks are becoming more and more common, but security 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 Security focuses on securing Linux in a networked environment, where the The security of the entire network needs to be considered rather than just isolated machines. It uses a mix of theoretical and practical techniques to teach administrators how to install and Use security applications, as well as how the applications work and why they are necessary.
$ wc testfile # Statistics information of the testfile file 3 92 598 testfile # Lines of the testfile file3Words92Bytes598
Among which,3 The numbers represent the line count, word count, and byte count of the testfile file, respectively.
If you want to count the information of multiple files at the same time, for example, to count the information of testfile and testfile_1、testfile_2You can use the following command:
wc testfile testfile_1 testfile_2 #Statistics of information of three files
Output results as follows:
$ wc testfile testfile_1 testfile_2 #Statistics of information of three files 3 92 598 testfile #Lines of the first file3Words92Bytes598 9 18 78 testfile_1 #Lines of the second file9Words18Bytes78 3 6 32 testfile_2 #Lines of the third file3Words6Bytes32 15 116 708 Total Usage #Total lines of three files15Words116Bytes708