Marco,

Using vi you can....

vi file.txt -w scriptfile

and any commands you enter in the editor will automatically be recorded 
and placed in the file "scriptfile".  (Just enter your global 
replacement command and exit.)

Now, on any file that you want to execute this script file against,  
issue ...

vi anyfile.txt -s scriptfile

and the "scriptfile" will be executed against "anyfile.txt"

I believe vi will internally create a temporary file but I'm assuming 
that you simply want to eliminate a manual step.  You'll have to create 
the scriptfile one time but after that, its a one line command each 
time without redirection.

Regards, Mike Klinke


On Saturday 04 January 2003 17:24, Marco Shaw 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.
>
> Can it be done?
>
> Marco



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

Reply via email to