wc Linux Command Cheatsheet




wc (word count) Linux Command is used to read standurd input or a list of files and generates new lines count or word count or byte count.

Syntax

wc [Option(s)] [file(s)]

Options

OptionDescription
-lprints lines count
-cprints byte count
-mprints character count
-Lprints length of longest line
-wprints word count

Examples

Lets take a file readme.txt with following content

$ cat readme.txt
Hello World line-1
Hello World line-2
Hello World line-3
Hello World line-4
Hello World line-5
Hello World line-6
Hello World line-7
Hello World line-8
Hello World line-9
Hello World line-10

Print lines count of a file

wc -l readme.txt #=>  10 readme.txt

Print words count of a file

wc -w readme.txt #=> 30 readme.txt

Print character count of a file

wc -c readme.txt #=> 191 readme.txt


┬ęCopyright 2020 OneCompiler | Privacy Policy | Terms & Conditions