Untitled Document
wc Command

wc - command is used to see how many lines are there in a file . If we run wc command without any option It will print number of words and characters along with line count . Lets run few examples and see the different options available with sc command .

Example 1 - Basic Example

Run the following wc command ,which will display lines, words and chracters from user.txt file .The file contains 4 lines , 12 words and 50 characters

   wc usr.txt     
   output - 4 12 50  

Example 2 Getting number of lines only ( -l ) option

Run the wc with ( - l ) option to get number of lines in a file .

   wc -l user.txt   

Example 3 - Getting number of words only ( -w ) option

Run the wc with ( -w ) option to get number of words in a file .

   wc -w user.txt  

Example 4 - Getting number of characters only ( -c ) option

Run the wc with ( -c ) option to get number of characters in a file .

  wc -c emp.csv 

Example 5 - wc with multiple files

When used with multiple filenames , wc produces a line for each file , as well as a total count .

  wc emp.csv user.txt logs.txt   
Untitled Document