Documentation
¶
Overview ¶
Package wc implements the wc builtin command.
wc — print newline, word, and byte counts for each file
Usage: wc [OPTION]... [FILE]...
Print newline, word, and byte counts for each FILE, and a total line if more than one FILE is specified. A word is a non-zero-length sequence of characters delimited by white space. With no FILE, or when FILE is -, read standard input.
When no flags are given, -l, -w, and -c are assumed (lines, words, bytes).
Accepted flags:
-l, --lines
Print the newline count.
-w, --words
Print the word count.
-c, --bytes
Print the byte count.
-m, --chars
Print the character count. In a multibyte locale, the number of
characters may differ from the number of bytes.
-L, --max-line-length
Print the length of the longest line.
--help
Print this usage message to stdout and exit 0.
Output columns always appear in a fixed order: lines, words, chars, bytes, max-line-length. Only the requested columns are shown. Column widths are right-justified to the width of the largest count across all files (including the total line, if any).
Exit codes:
0 All files processed successfully. 1 At least one error occurred (missing file, invalid argument, etc.).
Memory safety:
Input is read in fixed-size chunks (32 KiB). Lines longer than MaxLineBytes (1 MiB) are split across chunks for counting purposes but never fully buffered. All loops check ctx.Err() at each iteration to honour the shell's execution timeout.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Cmd = builtins.Command{Name: "wc", Description: "print newline, word, and byte counts", MakeFlags: registerFlags}
Cmd is the wc builtin command descriptor.
Functions ¶
This section is empty.
Types ¶
This section is empty.