man pages section 1: User Commands

Exit Print View

Updated: July 2014
 
 

wc(1)

Name

wc - display a count of lines, words and characters in a file

Synopsis

/usr/bin/wc [–c | –m | –C] [–lw] [file...]

Description

wc reads one or more input files and, by default, for each file writes a line containing the number of NEWLINEs, words, and bytes contained in each file followed by the file name to standard output in that order. A word is defined to be a non-zero length string delimited by isspace(3C) characters.

If more than one file is specified, wc writes a total count for all of the named files with total written instead of the file name.

By default, wc writes all three counts. Options can specified so that only certain counts are written. The –c and –m options are mutually exclusive.

If no file is specified, or if the file is -, wc reads from standard input and no filename is written to standard output. The start of the file is defined as the current offset.

Options

The following options are supported for both usr/bin/wc and ksh. The long form of the options are only available with ksh:

–c

Counts bytes.

–C

Counts characters. Same as –m.

–l

Counts lines.

–m

Counts characters. Same as –C.

–w

Counts words delimited by white space characters or new line characters. Delimiting characters are Extended Unix Code (EUC) characters from any code set defined by isspace(3C) .

If no option is specified, the default is –lwc (counts lines, words, and bytes.)

Operands

The following operand is supported:

file

A path name of an input file. If no file operands are specified, the standard input is used.

Usage

See largefile(5) for the description of the behavior of wc when encountering files greater than or equal to 2 Gbyte (231 bytes).

Environment Variables

See environ(5) for descriptions of the following environment variables that affect the execution of wc: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH.

Exit Status

0

Successful completion.

>0

An error occurred.

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Availability
system/core-os
CSI
Enabled
Interface Stability
Committed
Standard

See also

cksum(1), isspace(3C), iswalpha(3C), iswspace(3C), setlocale(3C), attributes(5), environ(5), largefile(5), standards(5)