views:

42

answers:

2

I am on a Solaris 8 box that does not support -i option for sed, so I am using the following from a google search on the topic:

# find . -name cancel_submit.cgi | while read file; do
> sed 's/ned.dindo.com\/confluence\/display\/CESDT\/CETS+DocTools>DOC Team/wwwin-dev.dindo.com\/Eng\/CntlSvcs\/InfoFrwk\/GblEngWWW\/Public\/index.html>EDCS Team/g' ${file} > ${file}.new
> mv ${file}.new ${file} 
> done

This works except it messes up file permissions and group:owner.

How can I retain the original information?

+1  A: 

You may use 'cat'.
cat ${file}.new > ${file} && rm ${file}.new

Gadolin
Great! Another good alternative. I actually used this one. Worked like a charm.
Kawili-wili
+2  A: 

cp -p preserves the stuff you want. Personally I would do this (to imitate sed -i.bak):

...
cp -p ${file} ${file}.bak
sed 's/..../g' ${file}.bak > ${file}
...

You could add rm ${file}.bak to the end if desired, in which case you wouldn't technically need the -p in the cp line above. But with the above you can do mv ${file}.bak ${file} to recover if the replacement goes awry.

Zac Thompson
Excellent! Thanks for a great option w/ backup.
Kawili-wili