wc Command

WC Command

This command is one of the daily use commands in Linux operating system, it should be known to every Linux user. 

With the help of this command, we can find out how many newlines, words and bytes are present in the file.

Suntax :

$wc [OPTION].... [FILE] ......

FILE :- Here we write the name of the file for which we want to find the number of newlines, words or bytes.

OPTION :- In this, we write the name of the options, which tell that after all we have to find the number of newlines, number of words or number of bytes of that file.   

There are many options of this command, we will know all these options in turn, as well as tell about how to use it. 

OPTIONS :-

* -c (or --bytes ) :- It is used to find the size of the file in bytes.

* -m (or --chars) :- Used to find the number of characters present in the file.

* -l ( or --lines) :- It is used to find the number of newlines in a file.

* -L (or --max-line-length ) :-It is used to find the size of the line with maximum width inside the file.

* -w (or --words ) :- It is used to find the number of words in the file.

* --help :- With the help of this we can see more information about this command. 

* --version :- If we want to see the version information of this command then we can use this option.

# Uses of wc command 

1. how many bytes are in the file?

Syntax :-

$ wc  -c  file_name

Or

$ wc  --bytes  file_name

-c (--bytes ) With the help of this option, we are going to find out how many bytes are in the file named my.txt. 


You can also have more than one file .


2. How many characters are in file ?

Syntax :

$ wc  -m  file_name

Or 

$ wc  --chars  file_name

-m (--chars) With the help of this option, we will find out how many characters are in the file named my.txt.


3. How many lines are in file ?

Syntax :

$ wc  -l  file_name

Or

$ wc  --lines  file_name 

-l ( --lines ) Now we are going to find out how many lines are present in the file named my.txt with the help of this option.


4. How to find the maximum width line size in a file ? 

Syntax :

$ wc  -L  file_name 

Or

$ wc  --max-line-length


5. How many words are in file ?

Syntax :

$ wc  -w  file_name

Or 

$ wc  --words  file_name 

Now we are going to find out how many words are in the my.txt file.


6. More option with file

If you use it without any option, in this case the number of line, words and characters are displayed respectively.



7. If we use command without any option then 

Syntax : 
 
$ wc  file_name 

If we use this command without any option then it displays line, word and character respectively. 
Ex:- 


8.  Finding Command Version 

We can find out the version of the command by using the --version option.

Syntax:

$ wc  --version


9. For any kind of help related to this command, you can take help like this 

Syntax : 

$ wc  --help


I have tried to make it easy to understand by taking the Linux manual page as a reference.

If you liked this article, please help others by sharing.If there is anything incorrect in this or it needs more improvement then you can comment me in the comment box below or contact at query.me.

Comments

Popular posts from this blog

ls command

ifconfig command