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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay