Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-06-2005, 04:42 AM   #1
Registered: Jun 2005
Location: Pune
Distribution: mandrake
Posts: 30

Rep: Reputation: 15
regarding linux commands

hello everyone,

can anyone tell me whats the command in linux which when given a pattern to search from a file will display me the lines which contain the pattern except the patten
i.e. if i want to find a pattern "/lib/tools.jar" in a file named abc,
the contents of abc are like

the result should be
(exactly opposite of the result which is displayed when we execute grep -o command)

thanks in advance
Old 09-06-2005, 05:18 AM   #2
Registered: Apr 2002
Location: UK, Sywell, EGBK
Distribution: RHEL, SuSE, CentOS, Debian, Ubuntu
Posts: 60

Rep: Reputation: 20
One method, without using any sophisticated Regular Expressions is to pass the pattern through sed:

sed -n '/pattern/s/pattern//p' file

That will process each line in the file, locating lines with the pattern. Every such line will have pattern replaced with nothing, the remainder will be printed out (s/pattern//p).
Old 09-06-2005, 05:27 AM   #3
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
The -v flag to grep will print only non-matching lines.


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
Linux commands please venu_112 Linux - Hardware 1 05-04-2005 10:00 AM
commands in linux lucbosian Linux - Newbie 2 10-04-2004 06:05 PM
Linux commands Skills Linux - Newbie 2 08-25-2004 04:24 AM
Linux commands mikkythomeon Linux - Newbie 3 02-19-2003 06:00 AM
linux commands eckomark Linux - Newbie 2 07-20-2001 10:43 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:15 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