Tuesday, June 17, 2008

wc

Use this command to count the number of characters, words, and lines in a file. Suppose, for example, that we have a file dict with contents

red rojo
green verde
blue azul
white blanco
black negro
Then we can do this
   % wc dict
5 10 56 tmp

This shows that dict has 5 lines, 10 words, and 56 characters.

The word count command has several options, as illustrated below:

   % wc -l dict
5 tmp
% wc -w dict
10 tmp
% wc -c dict
56 tmp

No comments: