![Unix/Linux Tutorials Word Count (wc) Command in UNIX/LINUX by Durga Sir](https://ytimg.googleusercontent.com/vi/Jxybw9blgsM/hqdefault.jpg)
————————————————– –
We can use wc command to count the number of lines, words and characters present in the given file.
WC file name
no_of_lines no_of_words no_of_chars file_name
For example:
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: On UNIX, each character will occupy 1 byte of memory. Therefore, the file size in bytes is exactly the same as the number of characters.
We can use the following options with wc command
-l To print only the number of lines
-w To print only the number of words
-c To print only the number of characters
-lw To print only the number of lines and words
-lc To print only the number of lines and characters
-wc To print only the number of words and characters
-L To print the 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
Please take the opportunity to connect and share this video with your friends and family if you find it useful.
No Comments