The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
grep unix.com with google



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-29-2009
Registered User
 

Join Date: Aug 2009
Posts: 18
omit strings from grep result

Hi,

I know this is a really dumb question, and I used to know how to do this, but I forgot and I can't seem to find the command online anywhere:

When I grep a string, how do I filter the results so that lines containing a certain string are OMITTED!

for example:
grep 'string' *.txt
gives:
1. string computer computer computer
2. string face face face


I only want the second line,
I know I can do:
grep 'string' *.txt | grep 'face'

but I would like to be able to do something like:
grep 'string' *.txt | ungrep 'computer'


where 'ungrep' is just my name for the unknown command I'm seeking

Thanks much!
  #2 (permalink)  
Old 11-29-2009
scottn scottn is offline Forum Staff  
Moderator
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,611

Code:
grep "string.*face" *.txt | grep -v computer

or


Code:
grep -E "string|face" *.txt | grep -v computer

  #3 (permalink)  
Old 11-29-2009
Registered User
 

Join Date: Nov 2008
Location: Amsterdam
Posts: 1,259
or just:

Code:
grep 'string' *.txt | grep -v computer



---------- Post updated at 16:19 ---------- Previous update was at 16:15 ----------


Code:
egrep -v "!(string)|computer" *.txt

Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to negate grep result? mmdawg Shell Programming and Scripting 4 05-05-2008 09:24 AM
diaplaying the grep result rag84dec Shell Programming and Scripting 1 03-27-2008 02:37 AM
append a string to a grep result melanie_pfefer Shell Programming and Scripting 8 03-19-2008 07:19 AM
grep to handle a 0 result ocelot UNIX for Dummies Questions & Answers 6 02-05-2007 11:19 AM
To have a numeric result from grep Hak Dee UNIX for Dummies Questions & Answers 2 08-07-2006 08:26 AM



All times are GMT -4. The time now is 02:01 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0