[thelist] stupid simple sed thing

Daniel J. Cody djc at members.evolt.org
Fri Mar 1 10:16:18 CST 2002


Hey Jay -

I was stumped how to do exactly the same thing for the longest time too,
it's a common problem :)

This is extremelly ugly, and might not work out for you, but its worked
for me in the past.

Pipe the results of the sed regex into 'cat' and have it write the file
for you, like so:

sed -e "s/.log/.frog/g" file.txt | cat > file.txt

Might take a bit o' tweaking on your part, but should do the trick.
Shout if you have any other probs :)

.djc.

Jay Greenspan wrote:
> I'm working on a shell script and am caught up on a simple task.
>
> I need to do a reg ex string replacement in a file. sed makes the
> replacement OK, but it gives the result to standard output,  and I can
> redirect the output to a file. But I can't replace the original file
> with the sed output. Is there a flag I'm missing here? Or is there
> another way I should be doing this? Just a simple string replacement in
> a file from the shell.




More information about the thelist mailing list