DEV Community

Cover image for wc command
Mohamed Yahia
Mohamed Yahia

Posted on • Edited on

wc command

The wc commands stands for word count

nuclearegg69@zenbook-f13:~$ ls
a  b  c  echo  empty  inNano3  inNano3.txt  inNanoRenamed  inNanoSymlink  testRen  testRen2
nuclearegg69@zenbook-f13:~$ nano a
nuclearegg69@zenbook-f13:~$ wc a
 5  5 58 a
Enter fullscreen mode Exit fullscreen mode

When we pass a file as an argument to wc and run it, it gives us three numbers: the first is the line count, the second is the word count, the third is the bytes count.

You can add options to wc to limit what you want

nuclearegg69@zenbook-f13:~$ wc -l a
5 a
nuclearegg69@zenbook-f13:~$ wc -w a
5 a
nuclearegg69@zenbook-f13:~$ wc -c a
58 a
nuclearegg69@zenbook-f13:~$ wc -m a
58 a

Enter fullscreen mode Exit fullscreen mode

-l option gives you the lines only
-w words only
-c bytes only
-m characters only

Top comments (0)