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
- Number of characters
- Number of words
- 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.
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
- Anisble: ERROR! unexpected parameter type in action:
Fix - June 29, 2020 - FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018