Re: how to use sed

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

 



On Wed, 2005-02-09 at 02:04 -0500, C. Linus Hicks wrote:

> Then I copied and pasted the exact command you gave above:
> 
> [linush@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?
> 

when you're playing with stuff like directories, that backslashing all
the slashes gets old quickly.  you can use any character for sed's
expression separator.  when i fool around with sed and directories, i
often use it like this:

sed 's%firstone%newone%g' ....
or
sed 's-/usr/bin/whatever-/new/path-g'

just makes it a lot easier than all those backslashes.  and more
readable and maintainable in the process.

john


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

  Powered by Linux