Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

saving ownership 2

Status
Not open for further replies.

farley99

MIS
Feb 12, 2003
413
US
I run that and it change the ownership in everyfile containing 208 to root, but i want to keep it as the current owner, how can i do this?

files=`grep -r 162 * -l | grep -v convert`
for ii in $files; do
echo "Processing $ii"
sed -e "s/162/208/" $ii >$ii.tmp;mv $ii.tmp $ii
done
 
Try this:
Code:
for ii in $files; do
  echo "Processing $ii";cp $ii $ii.tmp
  sed -e "s/162/208/" $ii.tmp >$ii;rm $ii.tmp
done
Or this if files are not huge:
Code:
for ii in $files; do
  echo "Processing $ii"
  echo '1,$s/162/208/\nwq' | ex -s $ii
done

Hope This Help
PH.
 
perl -pi.bak -e 's/162/208/' $files

Take out the .bak if you don't want backups of the files.

Annihilannic.
 
While another way ? What's wrong with the 2 I've suggested ?
 
Those were great hense the star, I am just wanting to learn all possible ways to do something like that. I appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top