Re: how to use sed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



----- Original Message ----- From: "naxis" <naxis@xxxxxxxxxxxxx>
To: <fedora-list@xxxxxxxxxx>
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@mail ~]$ cat foo
#!/usr/bonsaitools/bin/perl
[thomas.cameron@mail ~]$ sed "s/\/bonsaitools//" foo
#!/usr/bin/perl
[thomas.cameron@mail ~]$ sed "s/\/bonsaitools//" foo > zzz
[thomas.cameron@mail ~]$ mv zzz foo
[thomas.cameron@mail ~]$ cat foo
#!/usr/bin/perl

Using perl (better):

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


Certainly there are different/better ways.

Thomas


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux