Distributed Networks Home
DBWebApplications eWebProgrammer
prev prev
  Course navigation
    Embedded command syntax
The wc command
The UNIX word count command, wc, is used to count the number of lines, words, and characters in a file. Say you have a file called letter seen here:
$ cat letter
Dear Mom,
Final exams are coming up next week.
Please send food and money.
Love,
Susan
Run the wc command on this file:
$ wc letter
       8      16      90 letter
The wc command tells you that this file has 8 line, 16 words, and 90 characters. You can display just the number of lines using the –l option, the number of words by using the –w option, or the number of characters by using the –c option. Here is the same command using the –l option:
$ wc –l letter
8 letter
This limits the output to just the number of lines in the letter file.
  Course navigation