LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 10-25-2007, 11:59 PM   #1
i.you
Member
 
Registered: Oct 2006
Posts: 46

Rep: Reputation: 15
replacing sed -s option


Hi there,

Since I'm using BusyBox, no -s option in sed.
Only -efinr options in sed of BusyBox.
Any way instead of -s option?

The problem is :

sed -s 's/po/mo'

Should I install the regular sed program?
 
Old 10-26-2007, 12:09 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
You could enclose your sed command inside of a loop that handles each file, one-at-a-time.
 
Old 10-26-2007, 12:32 AM   #3
i.you
Member
 
Registered: Oct 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Thanks jschiwal,

Please have a look.
Is it right?
This is Makefile.

original:
...
out=`echo $$file | sed -s 's/po/mo/'` ; \
msgfmt -o $${out} $${file} ; \
if ...
fi ; \
...

modified:
...
for temp in s po mo ; do \
out=`echo $$file | sed $$temp` ; \
msgfmt -o $${out} $${file} ; \
if ...
fi ; \
done \
...
 
Old 10-28-2007, 12:08 PM   #4
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
I didn't realize that you were taking about makefiles. I think you should install gnu's sed program. It's only around 50K in size. You may want to install software someone else wrote, so it would be much easier installing the sed command once then having to rewrite a bunch of makefiles if 3rd party makefiles use the -p option.

You can use variable substitution instead. "msgfmt -o $${file%po}.mo" There is a form to do the same thing with the variables in a makefile as well. Or you could use a default rule which uses the extension.
The first iteration of your loop would expand to "out=`echo $file | sed s`;" That isn't what you are trying to do.

Also there are examples in the make info manual which use sed. I actually had to look up what the -s option did. Since you are using it to alter arguments and not edit files, I don't think it would be useful. It is used to reset the counter when handling each file in the filelist. Otherwise, the second file would be start as if it were appended to the first.

Last edited by jschiwal; 10-28-2007 at 01:05 PM.
 
  


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
[SOLVED] Replacing using sed with variables from another file? eamesj Programming 5 11-24-2006 10:20 AM
Help with sed - replacing strings thulley Linux - Software 4 08-22-2006 10:07 AM
sed help, replacing a letter with a word GridX Linux - Newbie 1 09-24-2003 10:21 AM
Replacing String with File Content in Sed meshcurrent Linux - General 2 06-01-2003 12:54 AM
replacing pattern with sed produces double realos Programming 1 10-17-2002 08:03 PM


All times are GMT -5. The time now is 05:56 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration