John Summerfied writes:
>Most times, when I "grep" the output I do so in a pipe. I used the quote
>because I also often use awk.
>
>The result of grepping is usually that most of the output is discarded.
>This illustrates my point without boring with the detail:
>[EMAIL PROTECTED] ~]$ locate ~ | wc -l
>114109
>[EMAIL PROTECTED] ~]$ locate ~ | grep A  | wc -l
>3479
>[EMAIL PROTECTED] ~]$
>
>For those who don't know what's going on:
>The tilde is replaced with the name of my home directory, so the locate
>command produces a list of files in my home directory and its
>subdirectories. wc as used just prints the number of lines.

Another problem with this approach is that the return code of the locate
command is lost.  This is because the shell defines the return code of a
pipe to be the return code of the last simple-command within the pipe.  So
if we "grep" output like this, we can't tell if the command we're
interested in succeeded or not.
        - MacK.
-----
Edmund R. MacKenty
Software Architect
Rocket Software, Inc.
Newton, MA USA

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to