In Unix, how do I get the line, word, or character count of a document?
In Unix, to get the line, word, or character count
of a document, use the
wc command. At the Unix
shell prompt, enter:
filename with the file or files for which you
want information. For each file,
wc will output
three numbers. The first is the line count, the second is the word
count, and the third is the character count. For example, if you
wc .login, the output would be something
similar to the following:
38 135 847 .login
To narrow the focus of your query, use one or more of the
Note: In some versions of
-m option will not be available or
will report characters. However, in most cases, the values for
-m are equal.
For example, to find out how many bytes are in the
file, you could enter:
wc -c .login
You may also pipe standard output into
determine the size of a stream. For example, to find out how
many files are in a directory, enter:
/bin/ls -l | wc -l
For more information about
wc, read its
man page. To do this, at the Unix prompt, enter:
At Indiana University, for personal or departmental Linux or Unix systems support, see At IU, how do I get support for Linux or Unix?
Last modified on September 16, 2010.