0

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?

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Great! Another good alternative. I actually used this one. Worked like a charm.
2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.