LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 06-23-2008, 07:09 AM   #1
raghuvamsi
LQ Newbie
 
Registered: May 2008
Posts: 20

Rep: Reputation: 0
how to use sed command


hi all

i wrote a script using sed to replace old text with new text.
and the script is like

#!/bin/bash

sed -i "s/Release: 1/Release: 1.%{mode}/" ./test1


and this is working fine if i execute it for the first time.
but the problem is when i execute it at the second time.

The output is

Release: 1.%{mode}.%{mode}

I want an option by which i can avoid this problem.

Is it possible to do that?

if not, please suggest me another method or command equivalent to sed.

Thank you.
 
Old 06-23-2008, 07:26 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Maybe because you're changing but not replacing: 'sed -i "s|something|somethingElse|g"'? If this is because of your .spec file then it may be easier to incorporate the %MODE in the %release tag and let an if-else-then statement handle it.
 
Old 06-26-2008, 01:17 AM   #3
raghuvamsi
LQ Newbie
 
Registered: May 2008
Posts: 20

Original Poster
Rep: Reputation: 0
hi
thanks for your suggestion.
Its working fine with if ... else statement.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
sed command shyamdey Programming 2 08-29-2006 11:06 PM
sed command ancys Programming 3 08-05-2006 09:30 AM
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

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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