Для всего вышеуказанного служит команда wc
.
man wc
NAME
wc -- word, line, character, and byte count
SYNOPSIS
wc [-Lclmw] [file ...]
...
The following options are available:
-L The number of characters in the longest input line is written to
the standard output. When more then one file argument is speci-
fied, the longest input line of all files is reported as the
value of the final ``total''.
-c The number of bytes in each input file is written to the standard
output. This will cancel out any prior usage of the -m option.
-l The number of lines in each input file is written to the standard
output.
-m The number of characters in each input file is written to the
standard output. If the current locale does not support multi-
byte characters, this is equivalent to the -c option. This will
cancel out any prior usage of the -c option.
-w The number of words in each input file is written to the standard
output.
...
ENVIRONMENT
The LANG, LC_ALL and LC_CTYPE environment variables affect the execution
of wc as described in environ(7).
EXIT STATUS
The wc utility exits 0 on success, and >0 if an error occurs.
EXAMPLES
Count the number of characters, words and lines in each of the files
report1 and report2 as well as the totals for both:
wc -mlw report1 report2
Find the longest line in a list of files:
wc -L file1 file2 file3 | fgrep total
HISTORY
A wc command appeared in Version 1 AT&T UNIX.