sed string replacement question

May 8, 2010 at 16:36:24
Specs: Windows Vista, amd 6400/4gb
Hey everybody. I've got a simple problem but am unsure how to resolve it. I am using a script to edit multiple files at once. Inside the script I am using an sed command to make the changes. My problem is that I can only get it to work for stings that contain a word or words. How can I modify it to change any kind of string? Thank in advance, here is what I have so far.

set p1="$1"
set p2="$1"
foreach x ($*)
if ( { grep -w -c "$p1" $x } ) then
mv $x $x.bak
sed "s/$p1/$p2/g" $x.bak > $x

See More: sed string replacement question

Report •

May 9, 2010 at 10:29:08
Take a look at this global regular expression substitution, gres, discussion:

Report •
Related Solutions

Ask Question