coreutils: wc invocation
1
1 6.1 ‘wc’: Print newline, word, and byte counts
1 ==============================================
1
1 ‘wc’ counts the number of bytes, characters, whitespace-separated words,
1 and newlines in each given FILE, or standard input if none are given or
1 for a FILE of ‘-’. Synopsis:
1
1 wc [OPTION]... [FILE]...
1
1 ‘wc’ prints one line of counts for each file, and if the file was
1 given as an argument, it prints the file name following the counts. If
1 more than one FILE is given, ‘wc’ prints a final line containing the
1 cumulative counts, with the file name ‘total’. The counts are printed
1 in this order: newlines, words, characters, bytes, maximum line length.
1 Each count is printed right-justified in a field with at least one space
1 between fields so that the numbers and file names normally line up
1 nicely in columns. The width of the count fields varies depending on
1 the inputs, so you should not depend on a particular field width.
1 However, as a GNU extension, if only one count is printed, it is
1 guaranteed to be printed without leading spaces.
1
1 By default, ‘wc’ prints three counts: the newline, words, and byte
1 counts. Options can specify that only certain counts be printed.
1 Options do not undo others previously given, so
1
1 wc --bytes --words
1
1 prints both the byte counts and the word counts.
1
1 With the ‘--max-line-length’ option, ‘wc’ prints the length of the
1 longest line per file, and if there is more than one file it prints the
1 maximum (not the sum) of those lengths. The line lengths here are
1 measured in screen columns, according to the current locale and assuming
1 tab positions in every 8th column.
1
11 The program accepts the following options. Also see ⇒Common
options.
1
1 ‘-c’
1 ‘--bytes’
1 Print only the byte counts.
1
1 ‘-m’
1 ‘--chars’
1 Print only the character counts.
1
1 ‘-w’
1 ‘--words’
1 Print only the word counts.
1
1 ‘-l’
1 ‘--lines’
1 Print only the newline counts.
1
1 ‘-L’
1 ‘--max-line-length’
1 Print only the maximum display widths. Tabs are set at every 8th
1 column. Display widths of wide characters are considered.
1 Non-printable characters are given 0 width.
1
1 ‘--files0-from=FILE’
1 Disallow processing files named on the command line, and instead
1 process those named in file FILE; each name being terminated by a
1 zero byte (ASCII NUL). This is useful when the list of file names
1 is so long that it may exceed a command line length limitation. In
1 such cases, running ‘wc’ via ‘xargs’ is undesirable because it
1 splits the list into pieces and makes ‘wc’ print a total for each
1 sublist rather than for the entire list. One way to produce a list
1 of ASCII NUL terminated file names is with GNU ‘find’, using its
1 ‘-print0’ predicate. If FILE is ‘-’ then the ASCII NUL terminated
1 file names are read from standard input.
1
1 For example, to find the length of the longest line in any ‘.c’ or
1 ‘.h’ file in the current hierarchy, do this:
1
1 find . -name '*.[ch]' -print0 |
1 wc -L --files0-from=- | tail -n1
1
1 An exit status of zero indicates success, and a nonzero value
1 indicates failure.
1