This directory of Linux commands is from Linux in a Nutshell, 5th Edition.
Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.
wc [options] [files]
Print byte, word, and line counts for each file. Print a total line for multiple files. If no files are given, read standard input. See other examples under ls and sort.
Count the number of users logged in:
who | wc -l
Count the words in three essay files:
wc -w essay.
Count lines in the file named by variable $file (don't display filename):
wc -l < $file