how to use sed
john bray
jmblin at comcast.net
Wed Feb 9 08:12:11 UTC 2005
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 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?
>
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
More information about the users
mailing list