Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 11-21-2003, 12:17 AM   #1
Registered: Apr 2003
Location: Singapore
Distribution: Slackware32/64, Ubuntu, Fedora, RHEL
Posts: 138

Rep: Reputation: 15
grep exclude


I have man the pages for grep but couldn't find anything about exclude text.

I use 'grep searchtext filename' to get the result of searchtext.
However, I do not know how to exclude certain text from this search.

Can grep do this?

Old 11-21-2003, 04:12 AM   #2
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
You make an inverse grep: grep -v text_to_avoid.
Old 11-21-2003, 05:15 AM   #3
Registered: Apr 2003
Location: Singapore
Distribution: Slackware32/64, Ubuntu, Fedora, RHEL
Posts: 138

Original Poster
Rep: Reputation: 15
** SOLVED **

Thank you..

ah ha, inverse=reverse=exclude.
Old 10-12-2010, 07:36 PM   #4
LQ Newbie
Registered: Oct 2010
Posts: 1

Rep: Reputation: 0
Wink grep exclude command

I am new to Linux,
Anybody knows how to use grep to exclude 3 and 5 letters words from a file which have each word on its own line! To mention the words can be on extended lenght of letter size (words of 2,3,4,5,6,7, etc letters, one word per line. Use the 2 greps on the same command: the first to exclude 3 letter words, follow by the second to exclude 5 letter words

Please advice if you can help me to solve this puzzle

Old 10-12-2010, 08:50 PM   #5
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 101Reputation: 101
egrep -v '3|5'.


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using find and grep - how to exclude a result ? graziano1968 Linux - General 13 12-04-2010 10:02 PM
tar --exclude --exclude-from cefn Linux - Software 4 10-11-2005 07:31 PM
grep ?? can grep us variables? DaFrEQ Linux - Software 4 09-14-2005 12:22 PM
How can I filter the output of grep to exclude certain cases? QtCoder Linux - General 1 03-28-2004 12:05 AM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:14 AM.

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