wc command in UNIX
wc [OPTION]... [FILE]...wc [OPTION]... --files0-from=FIntroduction
Section titled “Introduction”wc command prints newline, word and byte counts for each FILE, and a total line if more than one FILE is specified.
Note that a word is a non-zero-length sequence of characters delimited by white space.
With no FILE, or when FILE is -, wc command reads from standard input.
Options
Section titled “Options”The options below may be used to select which counts are printed, always in the following order: newline, word, character, byte, maximum line length.
-c,--bytes: print the byte counts-m,--chars: print the character counts-l,--lines: print the newline counts--files0-from=F: read input from the files specified byNUL-terminated names in fileF-L,--max-line-length: print the maximum display width-w,--words: print the word counts
Examples
Section titled “Examples”wc is often used with pipe operator together with previous commands.
# use it all alonewc silvia.txt 18 85 454 silvia.txtPrint the character counts that makes the names of 3 last modified files in $HOME directory:
ls -t $HOME | head -n 3 | wc -c27 # this number will change very often, off courseCount connected users:
who | wc -l5
# as counter-checkwhopit tty1 2022-03-21 13:38 (:0)pit pts/0 2022-03-21 13:38 (:0)pit pts/2 2022-03-21 16:08 (:0)pit pts/3 2022-03-21 16:31 (:0)pit pts/4 2022-03-21 16:41 (:0)Quotes
Section titled “Quotes”Here are some useful links I used while writing this article: