Wc (Unix)
From Wikipedia, the free encyclopedia
- The correct title of this article is wc. The initial letter is shown capitalized due to technical restrictions.
wc (short for word count) is a command in Unix-like operating systems.
The program reads either standard input or a list of files and generates one or more of the following statistics: number of bytes, number of words, and number of lines (specifically, the number of newline characters). If a list of files is provided, both individual file and total statistics follow.
Sample execution of wc:
$ wc ideas.txt excerpt.txt 40 149 947 ideas.txt 2294 16638 97724 excerpt.txt 2334 16787 98671 total
The first column is the count of lines, the second column is words, and the last column is number of characters.
Newer versions of wc can differentiate between byte and character count. This difference arises with Unicode which includes multi-byte characters. The desired behaviour is selected with the -c or -m switch.
GNU wc is part of the GNU textutils package.
[edit] Usage
wc -l <filename> print the line count wc -c <filename> print the byte count wc -m <filename> print the character count wc -L <filename> print the length of longest line wc -w <filename> print the word count
[edit] See also
[edit] External links
Unix command line programs (more) | |||
File and file system management: | cat | cd | chmod | chown | chgrp | cp | du | df | file | fsck | ln | ls | lsof | mkdir | more | mount | mv | pwd | rm | rmdir | split | touch | tree | ||
Process management: | anacron | at | chroot | crontab | kill | killall | nice | pgrep | pidof | pkill | ps | sleep | screen | time | timex | top | wait | ||
User Management/Environment: | env | finger | id | locale | mesg | passwd | su | sudo | uname | uptime | w | wall | who | whoami | write | ||
Text processing: | awk | cut | diff | ex | head | iconv | join | less | more | nkf | paste | sed | sort | tail | tr | uniq | wc | xargs | ||
Shell programming: | echo | expr | printf | unset | Printing: | lp |
Communications: inetd | netstat | ping | rlogin | traceroute |
Searching: find | grep | strings |
Miscellaneous: banner | bc | cal | man | size | yes |