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 - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-12-2004, 07:33 PM   #1
feetyouwell
Member
 
Registered: Dec 2003
Location: NC, US
Distribution: Novell Linux Eval (2.6.5)
Posts: 240

Rep: Reputation: 30
question about using sed command


sed usage is like
Code:
 s/find/replace/
how can you put in there so sed only replace the WHOLE regular expression <find>

here is the problem i ran into

my sed file is like
Code:
s/_P0/.L0/
s/_P2/.L0/
s/_P0/.L1/
s/_P2/.L1/
s/_P1/.L2/
s/_P3/.L2/
s/_P4/.L3/
s/_P5/.L4/
s/_P5/.L5/
s/_P7/.L5/
s/_P6/.L6/
s/_P8/.L6/
s/_P9/.L7/
s/_P10/.L9/
s/_P10/.L10/
s/_P12/.L10/
s/_P11/.L11/
s/_P13/.L11/
therefore, the it sees _P12, it replaces _P1 with .L2 so i ended up having .L22 which is not what i want, how to fix those!!!
 
Old 12-12-2004, 07:48 PM   #2
winsnomore
Member
 
Registered: May 2004
Location: USA
Distribution: #1 PCLinuxOS -- for laughs -> Ubuntu, Suse, Mepis
Posts: 315

Rep: Reputation: 31
not sure if your last three enteries are correct...
you don't need to replace the numerals .. just do s/_P/.L/
and that will be fine for all entries ..
 
Old 12-12-2004, 07:52 PM   #3
feetyouwell
Member
 
Registered: Dec 2003
Location: NC, US
Distribution: Novell Linux Eval (2.6.5)
Posts: 240

Original Poster
Rep: Reputation: 30
the sed file i showed is a code generated file, it's a backpatching method used in creating a compiler, so i can't just delete the number out the _P, do you have any idea how to do s/<fix regexp>/replace here? thanks
 
Old 12-12-2004, 08:17 PM   #4
feetyouwell
Member
 
Registered: Dec 2003
Location: NC, US
Distribution: Novell Linux Eval (2.6.5)
Posts: 240

Original Poster
Rep: Reputation: 30
nevermind, i fixed, i added a '_' at the end of each find_string, so sed has to find a _ in order to complete searching, that worked like a charm
 
Old 12-13-2004, 08:47 AM   #5
zulfilee
Member
 
Registered: Apr 2004
Location: India
Distribution: Redhat,Fedora
Posts: 430

Rep: Reputation: 39
The easiest way could have been if you changed the order :-)

(i.e) P12 first and P1 next. Nevermind you had somethin else in mind.

Cheers
Z
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
sed command rharris72 Programming 6 11-20-2005 08:26 PM
sed command pazvant Linux - Software 2 05-09-2004 12:58 PM
sed command linuxdev Linux - Newbie 9 02-24-2004 04:50 PM
sed Command linuxdev Linux - Newbie 3 02-09-2004 11:27 AM
sed command kwigibo Linux - General 3 04-21-2002 04:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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