Counts the number of lines, words, and bytes or characters in a file.
wc [ -c | -m ] [ -l ] [ -w ] [ File ... ]
wc -k [ -c ] [ -l ] [ -w ] [ File ... ]
By default, the wc command counts the number of lines, words, and bytes in the files specified by the File parameter. The command writes the number of newline characters, words, and bytes to the standard output and keeps a total count for all named files.
When you use the File parameter, the wc command displays the file names as well as the requested counts. If you do not specify a file name for the File parameter, the wc command uses standard input.
The wc command is affected by the LANG, LC_ALL, LC_CTYPE, and LC_MESSAGES environment variables.
This command returns the following exit values:
0 | The command ran successfully. |
>0 | An error occurred. |
wc chap1The wc command displays the number of lines, words, and bytes in the chap1 file.
wc -cw chap*The wc command displays the number of bytes and words in each file that begins with chap. The command also displays the total number of bytes and words in these files.
wc -k chap1The wc command displays the number of lines, words, and characters in the chap1 file.
wc -kcw chap1The wc command displays the number of characters and words in the chap1 file.
wc -klwThe wc command displays the number of lines and words in standard input. The -k flag is ignored.
wc -m chap1The wc command displays the number of characters in the chap1 file.
wc -mlwThe wc command displays the number of lines, words, and characters in standard input.
/usr/bin/wc, /bin/wc | Contains the wc command. |
/usr/ucb/wc | Contains the symbolic link to the wc command. |
Files Overview and Input and Output Redirection Overview in AIX Version 4.3 System User's Guide: Operating System and Devices.
National Language Support Overview for System Management in AIX Version 4.3 System Management Concepts: Operating System and Devices.