“ wc ” command stands for “word count”.
“ wc “ command in Unix/Linux OS is used to calculate/find out and print the number of lines, number of words, number of character and byte of a file.
Syntax:
$ wc [option] [filename]
Example: There is a sample file file01.txt.
1 2 3 | Hello I am Aditya from NIT Patna My roll number 720/06 |
Type command on terminal…
1 2 | $ wc file01.txt [press enter] 3 11 44 [output ] |
The above command displays the output “ 3 11 44 “. Where 3 is a number of lines, 11 is the number of words and 44 is a number of character on a specified file “ file01.txt”.
Options of “wc” command are:
[table id=6 /]
(-l) option: wc command with –l option is used to print the number of lines in a file. Type below command on terminal
1 2 3 | $ wc -l file01.txt [press enter] 3 [output ] |
The above command displays the output “3”. Where 3 is a number of lines on a specified file “ file01.txt”.
(-w) option: wc command with –w option is used to print the number of words in a file. Type below command on terminal…
1 2 3 | $ wc -w file01.txt [press enter] 11 [output ] |
The above command displays the output “ 11 “. Where 11 is the number of words in a specified file “file01.txt”.
(-c) option: wc command with –c option is used to print the number of character in a file. Type below command on terminal…
1 2 3 | $ wc -c file01.txt [press enter] 44 [output ] |
The above command displays the output “ 44 “. Where 44 is a number of character of words in a specified file “ file01.txt”.