WC command with examples

This is a small post on how to us wc(Word Count) command in Linux and Unix. WC command is a basic command which can give you good statics of the file content such as

  1. Number of characters
  2. Number of words
  3. Number of Lines
In all these options get number of lines of a file/output is frequently used. Lets learn wc command with examples

Example1: How can display or get number of character in my file?

wc -c filename.txt

Example2: I want to count number of words in a file in Linux, how can I do that?

wc -w  filename.txt

Example3: Count number of lines in a given file output

wc -l filename.txt

Example4: How can I get number of files in a given directory

ls | wc -l

To get more help on wc command read man pages

man wc


The following two tabs change content below.
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.