Within the /usr/share directory hierarchy, list the number of times the word 27 occurs in files in which it occurs at least once. Hint: Connect the output of one grep command to the input of another grep command using a pipe; the first grep command should display the count for all files in the hierarchy and the second should get rid of those with a count of 0.
What will be an ideal response?
$ grep -rwc 27 /usr/share | grep -v ':0$'
...
When you call grep with a list of files, the –c option causes grep to append
to each filename a colon (:) and the number of matches that occur in that
file. To satisfy this exercise, you must find all lines that do not end in :0 and
accept lines that end in numbers such as :20.
The second grep command uses the –v option to return all lines that do not
match the quoted regular expression (:0$). The $ matches the end of a line
(Sobell, page 1042). The single quotation marks are required to prevent the
shell from interpreting the dollar sign as a special character.
You might also like to view...
By default, Access will sort records on a Report by ________
Fill in the blank(s) with correct word
As each new bulleted item is added, the entry is automatically ________ 1/4 inch
Fill in the blank(s) with correct word