Most of the times, when we work with scripting programs,
we might encounter with a requirement of counting the number of lines of a file for writing the logic. We may want to count the lines/words/characters of a command output.
This kind of requirements are best addressed by “wc command”.
wc command syntax:
Checking the lines,words and characters in a file:
From the output,
1st column represents number of line in file
2nd column represents number of words in file
3rd column represents number of characters in file.
Counting the words in a file or in a content:
Counting the lines in a file or in an output:
We can also count number of line in more than one file, also.
Printing the byte counts of the file:
By using "-c" option with wc command we can print the byte counts of a particular file.
Printing the length of largest line:
By using "-L" option with wc command we can print the length of largest line of a particular file.
Printing the new line count or Line count:
By using "-l" option with wc command we can print the new line (/n or enter) count of the particular file.