On 13:24 04 Jan 2003, Marco Shaw <[EMAIL PROTECTED]> wrote:
| What I want:
| Take file.txt and *strip* out "foo" and replace with "bar", *but* I
| don't want to redirect to a tmp file or anything:  I would like one
| command.
| 
| Perl:
| 1. perl -pi -e 's/foo/bar/g' file.txt
| 
| SED, for example:
| 1. sed 's/foo/bar/g' file.txt > file.txt.tmp
| 2. mv file.txt.tmp file.txt
| 
| So perl does what I want to, but I'd prefer to stay with awk, sed, or
| whatever GNU utils, if possible.

Then you want "bsed":

        http://www.zip.com.au/~cs/scripts/bsed

thus:

        bsed 's/foo/bar/g' file.txt

Bsed is a shell wrapper for sed. I use it VERY heavily - it's remarkably
useful to me.

If you want something more flexible (but also more cumbersome) you might grab
filteredit:

        http://www.zip.com.au/~cs/scripts/filteredit

thus (example):

        filteredit file.txt awk '{print NR, $0}'

It's a wrapper for _any_ filterlike command, to edit in place.

Cheers,
-- 
Cameron Simpson, DoD#743        [EMAIL PROTECTED]    http://www.zip.com.au/~cs/

It's like a roller-coaster ride where you can't throw up.
       Radio commentator on a certain basketball team's current season



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to