UNIX, Third Edition
Counting Files and Their Contents with wc
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. Code Listing 6.1. Use wc -w to count the words in a file. The "honey-do" list in this example is quite a way from being the length of a novel.
Code Listing 6.2. With 85 separate items in the list, however, it's plenty long enough.
To count words using wc:
To count lines with wc:
|
Категории