13 January 2012

wc command in Linux/Unix

1 comment
wc command in Linux/Unix


                                             wc is short form for word count . wc counts number of lines , words and characters in a file.

Syntax


                    wc  [option]  filename


Example
$ wc abc.lst

2 8 31 abc.lst

* 2 = Number of lines.
* 8 = Number of words.
* 31 = Number of bytes.
* abc.lst = Name of the file.


Instead of printing all the counts , we can print specific count by using different options

1. -l : Only print number of lines in a file.

$ wc -l  abc.lst
2 abc.lst

2. -c : Only print number of bytes in a file.

3. -w : Only print number of words in a file.

4. -m  : print the character counts in a file.

$ wc -c abc.lst
31 abc.lst

$ wc -w abc.lst
8 abc.lst


$ wc -m abc.lst
31 abc.lst

5. -L :  print the length of the longest line in a file.

$ wc -L abc.lst
15 abc.lst





If You Liked This Post Please Take a Time To Share This Post

You May Also Like...

1 comment:

  1. Great explanation. please check our website at https://www.techcarbasa.com/

    ReplyDelete