how to use sed

Thomas Cameron thomas.cameron at camerontech.com
Wed Feb 9 06:58:52 UTC 2005


----- Original Message ----- 
From: "naxis" <naxis at valiansys.com>
To: <fedora-list at redhat.com>
Sent: Tuesday, February 08, 2005 11:57 PM
Subject: how to use sed


> 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

Using sed (clunky):

[thomas.cameron at mail ~]$ cat foo
#!/usr/bonsaitools/bin/perl
[thomas.cameron at mail ~]$ sed "s/\/bonsaitools//" foo
#!/usr/bin/perl
[thomas.cameron at mail ~]$ sed "s/\/bonsaitools//" foo > zzz
[thomas.cameron at mail ~]$ mv zzz foo
[thomas.cameron at mail ~]$ cat foo
#!/usr/bin/perl

Using perl (better):

[thomas.cameron at mail ~]$ cat foo
#!/usr/bonsaitools/bin/perl
[thomas.cameron at mail ~]$ perl -pi -e 's/\/bonsaitools//' foo
[thomas.cameron at mail ~]$ cat foo
#!/usr/bin/perl


Certainly there are different/better ways.

Thomas




More information about the fedora-list mailing list