LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 09-06-2005, 04:42 AM   #1
neerajchaudhari
Member
 
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
/usr/j2sdk/java/lib/tools.jar

the result should be
/usr/j2sdk/java
(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
alinas
Member
 
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
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

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


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
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


All times are GMT -5. The time now is 08:51 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration