wc command in unix is used to find the number of lines, characters, words in a file. It Print newline, word, and byte counts for each FILE, and a total line if more than one FILE is specified. With no FILE, or when FILE is dash("-"), read standard input.
The syntax for wc command isThe options are
- -c: Prints the byte count
- -l: Prints the line count
- -L: Prints the length of the longest line
- -m: Prints the character count
- -w: Prints the word count
For example below text is the unix file
> cat unix.txt
unix is file
linux is server
- Count the number of lines in a file.
wc -l unix.txt
It gives 2 s the output.
- Count the number of words in a file.
It gives 6 as the output.
- For any help on command, run below command.