With wc instruction, we can calculate the number of bytes, words, or columns of the file. If we do not specify the file name or the given file name is "-", wc instruction will read data from the standard input device.
- -c or -- Bytes or -- chars displays only the number of Bytes.
- -l or -- lines displays only the number of rows.
- -w or -- words displays only the number of words.
- --Help online help.
- --Version displays version information.
By default, wc calculates the number of lines, words, and bytes for the specified file. The commands used are:
First, check the contents of 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.
Using wc statistics, the results are as follows:
$ wc testfile # Statistics for testfile files 3 92 598 testfile # testfile file has 3 lines, 92 words and 598 bytes
Among them, three numbers represent the number of lines, words and bytes of testfile file.
If you want to count the information of multiple files at the same time, such as testfile, testfile_1,testfile_2. You can use the following command:
wc testfile testfile_1 testfile_2 #Statistics of three files
The output results are as follows:
$ wc testfile testfile_1 testfile_2 #Statistics of three files 3 92 598 testfile #The first file has 3 lines, 92 words and 598 bytes 9 18 78 testfile_1 #The second file has 9 lines, 18 words and 78 bytes 3 6 32 testfile_2 #The third file has 3 lines, 6 words and 32 bytes 15 116 708 Total dosage #The total number of lines, words and bytes of the three files is 15, 116 and 708