LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Command syntax question for grep (https://www.linuxquestions.org/questions/linux-software-2/command-syntax-question-for-grep-656165/)

kaplan71 07-16-2008 11:56 AM

Command syntax question for grep
 
Hi there --

I am running a script that includes the following grep statement:

Code:

grep -v ' OK' clamscan_output.txt > /tmp/clamscan_outputsummary.txt
I would like to modify the above statement so that in addition to removing any lines that include 'OK', lines that include 'Empty file' are also removed from the output.

How can this be done? Thanks.

colucix 07-16-2008 11:57 AM

Code:

grep -v ' OK' clamscan_output.txt | grep -v 'Empty file' > /tmp/clamscan_outputsummary.txt

forrestt 07-16-2008 11:59 AM

You can do it by specifying your expressions with the -e option like:

Code:

grep -v -e ' OK' -e 'Empty file' clamscan_output.txt > /tmp/clamscan_outputsummary.txt
HTH

Forrest

kaplan71 07-16-2008 12:02 PM

I tried the syntax you suggested, and it worked. Thanks for the help.

Mr. C. 07-16-2008 02:13 PM

or use egrep and the or | operator.

egrep -v ' OK|Empty file' clamscan_output.txt


All times are GMT -5. The time now is 04:05 AM.