Quantcast
Viewing all articles
Browse latest Browse all 6

word count

Word count is a very common tools that used to calculate number of lines, words and characters. For example if I can do this

echo "hello world." | wc
1       2      13

The result indicate that there are 1 line, 2 words and 13 characters.

You can output result separately, -c indicates characters, -w indicate words, -l indicate lines.

echo "hello world." | wc -c

You can count for any file even binaries by using -c

cat hello.c | wc -c

Try to check with ls -l hello.c, you will discover that, the characters count is actualy same as the bytes of the files.

Therefore,

cat `which cat` | wc -c

is actually returns file size of cat binaries in terms of number of bytes.


Viewing all articles
Browse latest Browse all 6

Trending Articles