Check the number of characters and lines in a file
The wc command is used to check the number of characters and lines in a file. To check the number of characters, use "-c" as an option, and to check the number of lines, use "-l".
To execute the wc command, specify the name of the file you want to investigate as an argument.
●Find the number of lines, words and bytes in a file
[nuy@Lion nuy]$ wc sample.txt 42 772 2058 sample.txt ↑From left to right: number of lines, number of words, number of bytes |
●Find the number of bytes
[nuy@Lion nuy]$ wc -c sample.txt 2058 sample.txt |
●Find the number of lines
[nuy@Lion nuy]$ wc -l sample.txt 42 sample.txt |