One of UNIX's handiest capabilities lets you count files and their contents. For example, you can count the number of files in a directory, or you can count the number of words or lines in a file. You do this counting with the wc command, as shown in Code Listing 6.1.
To count words using wc:
wc -w honeydo
To count lines with wc:
wc -l honeydo
Tip
You can find out how many files you have in a directory by using ls | wc -l to count the regular files, or ls -A | wc -l -2 to count all files and directories (except for the . and .. directories).
Tip
You can also find out how many bytes a specific file takes up using wc -b. Or, you can use wc with no flags at all to get the lines, words, and bytes.
[ejr@hobbes manipulate]$ wc -w honeydo 235 honeydo |
[ejr@hobbes manipulate]$ wc -l honeydo 85 honeydo |
3.145.179.225