Click to See Complete Forum and Search --> : need help with sed command please


alaskian
08-29-2002, 01:34 PM
i am currently trying out some sed commands, and the command works if i pipe it to an output file, however, won't update the current file i'm working with. do i just not know sed correctly? example, i have the following file called list which contains the following lines:

John Doe 123 Hollywood Drive, San Francisco CA
Mary Jane 845 Woods Drive, Minnesota, MN

If I type the following command at the linux prompt, the correct correction displays, however, isn't saved to the file "list". but if i pipe it out to an output file, the results are then put into the output file. is this how sed works or am i missing something. here is the following replace command i am using to replace CA with California.

sed 's/CA/California/' list - this command does not save

sed 's/CA/California/' list > output will save the corrected replacement in file output

Any help would be greatly appreciated!! Thanks!

Rüpel
08-29-2002, 05:08 PM
this is exactly the way sed works. everything's fine. do a
mv output list
afterwards and you're done.

rapskat
08-30-2002, 04:42 AM
You might want to try this and see if it works for you:

sed -e 's/CA/California/g' list

Pretty much the same thing, just with the -e option which shouldn't even really be necessary and the g switch to make it run globally throughout the entire file.

HTH