how to use sed

C. Linus Hicks lhicks at nc.rr.com
Wed Feb 9 07:04:10 UTC 2005


On Wed, 2005-02-09 at 14:57 +0900, naxis wrote:
> Sorry to bother you with this but I want to know.
> I tried to use sed to change the perl path of my cgi scripts in a
> directory.
> from /usr/bonsaitools/bin/perl to /usr/bin/perl
> #sed 's/\/usr\/bonsaitools\/bin\/perl/\/usr\/bin\/perl/g' *.cgi
> it didnt work so I changed every thing one by one but I know sed can do
> the job for me.
> can someone teach me that?
> thank you

You didn't say how it didn't work. I created a file junk1:

[linush at lh4 ~]$ cat junk1
/usr/bonsaitools/bin/perl
/usr/bonsaitools/bin/perl
/usr/bonsaitools/bin/perl   /usr/bonsaitools/bin/perl

Then I copied and pasted the exact command you gave above:

[linush at lh4 ~]$ sed 's/\/usr\/bonsaitools\/bin\/perl/\/usr\/bin\/perl/g' junk1
/usr/bin/perl
/usr/bin/perl
/usr/bin/perl   /usr/bin/perl

It appears to work just fine. Are you aware that sed will not make
changes to the file, but rather sends the updated contents to stdout
unless you use -i?

-- 
C. Linus Hicks <lhicks at nc dot rr dot com>




More information about the fedora-list mailing list