Text-Related Commands
One of the original design goals of UNIX at AT&T was for processing of text data. UNIX and FreeBSD include a large number of commands for processing text data from the command line. I'm not going to try to cover every single command available, but I am going to cover the most useful ones.
Counting Lines, Words, and Characters
Use the wc command to count the number of lines, words, and characters in a text file. With no options, it will give all three. For example, the following tells me that there are 1160 lines, 7823 words, and 51584 characters currently in the text file that contains this chapter of the book:
$ wc fbu8mcu 1160 7823 51584 fbu8mcu.html
wc supports the -l option to only display number of lines, the -w
Get FreeBSD® Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.