LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 07-16-2008, 12:56 PM   #1
kaplan71
Member
 
Registered: Nov 2003
Posts: 719

Rep: Reputation: 39
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.
 
Old 07-16-2008, 12:57 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Code:
grep -v ' OK' clamscan_output.txt | grep -v 'Empty file' > /tmp/clamscan_outputsummary.txt
 
Old 07-16-2008, 12:59 PM   #3
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
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
 
Old 07-16-2008, 01:02 PM   #4
kaplan71
Member
 
Registered: Nov 2003
Posts: 719

Original Poster
Rep: Reputation: 39
I tried the syntax you suggested, and it worked. Thanks for the help.
 
Old 07-16-2008, 03:13 PM   #5
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
or use egrep and the or | operator.

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with grep syntax and reg exp Rush_898 Linux - General 2 01-08-2008 11:28 AM
grep CLI syntax: how to find A OR B? Kropotkin Linux - Newbie 3 01-16-2007 10:45 PM
grep script/syntax carriehoff Linux - Newbie 6 08-31-2006 02:13 PM
Simple question about command syntax ping/log ping results ohalnet Linux - Networking 1 07-25-2006 05:46 AM
Grep syntax questions Phaethar Linux - General 4 04-11-2005 10:34 AM


All times are GMT -5. The time now is 07:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration