100 Useful Command-Line Utilities

by Oliver; 2014

24. wc

wc counts the number of words, lines, or characters in a file.

Count lines:
$ cat myfile.txt
aaa
bbb
ccc
ddd
$ cat myfile.txt | wc -l
4
Count words:
$ echo -n joe | wc -w
1
Count characters:
$ echo -n joe | wc -c
3

<PREV   NEXT>