LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-07-2008, 12:32 AM   #1
Viper Chief
LQ Newbie
 
Registered: Apr 2008
Posts: 24

Rep: Reputation: 15
grep -v for foo or bar


I've done a Google search and haven't found anything for this. I'm looking for a way to read a file excluding all lines containing either foo or bar. I know that grep -v foo file will give me all lines not containing foo, but I can't figure out how to grep the file for lines not containing foo or bar. I'm sure there's a way to do it, but I've been experimenting for the last hour and have come up with nothing.
 
Old 05-07-2008, 12:36 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
egrep -v "foo|bar" file
 
Old 05-07-2008, 02:52 AM   #3
Viper Chief
LQ Newbie
 
Registered: Apr 2008
Posts: 24

Original Poster
Rep: Reputation: 15
Thank you very much!
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What is foo bar satimis Programming 25 04-26-2019 08:21 PM
BASH get marked RegEx result: "foo s bar" | /foo(.*)bar/ 1 -> " s " hansschmucker Programming 6 10-23-2007 10:34 PM
foo@bar:~$ <- how to change bar? JussiKp Linux - Newbie 4 08-03-2006 05:46 AM
For foo in bar; do angel115 Programming 1 11-16-2005 04:52 PM
grep -r foo /* alles32 Linux - General 2 09-19-2004 06:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:34 AM.

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
Open Source Consulting | Domain Registration