Word Count Command (wc command):
----------------------------------------------
We can use wc command to count number of lines,words and characters present in the given file.
$ wc filename
no_of_lines no_of_words no_of_chars file_name
eg:
durgasoft@durgasoft:~/Desktop$ wc file1.txt
4 16 78 file1.txt
4 ---The number of lines
16 ---The number of words
78 ---The number of characters (File size in bytes)
Note: In UNIX, each character will take 1 byte memory. Hence file size in bytes is exactly same as number of characters.
We can use the following options with wc command
-l === To print only number of lines
-w === To print only number of words
-c === To print only number of characters
-lw === To print only number of lines and words
-lc === To print only number of lines and characters
-wc === To print only number of words and characters
-L ==== To print number of characters present in the Longest Line.
We can use wc command for multiple files simultaneously.
$ wc file1.txt file2.txt file3.txt
5 17 140 file1.txt
4 6 91 file2.txt
7 9 129 file3.txt
16 32 360 total
#DURGASOFTWARE #UNIX/LINUX #WordCountCommand
Download
0 formats
No download links available.
Unix/Linux Tutorials | Word Count (wc) Command in UNIX/LINUX | by Durga Sir | NatokHD