Showing posts with label wc in unix. Show all posts
Showing posts with label wc in unix. Show all posts

Friday, October 9, 2015

Getting word count from file in unix/linux

syntax: wc filename

WC command will display the total number of lines, words and characters from file.

Example: $ wc filename

2 30 100 filename

First column - Total number of lines (2 lines in example file)
Second column - number of words (30 words in example file)
Third column - number of characters (100 characters in example file)

To get only line count from file

$ wc -l filename

2 filename

To get only word count from file

$ wc -w filename

30 filename

To get only character count from file

$ wc -c filename

100 filename