Name
wc
Synopsis
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.
Options
- -c, --bytes
Print byte count only.
- -l, --lines
Print line count only.
- -L, --max-line-length
Print length of longest line.
- -m, --chars
Print character count only.
- -w, --words
Print word count only.
- --help
Print help message and then exit.
- --version
Print the version number and then exit.
Examples
Count the number of users logged in:
who | wc -l
Count the words in three essay files:
wc -w essay.[123]
Count lines in the file named by variable $file (don’t display filename):
wc -l < $file
Get Linux in a Nutshell, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.