View Single Post
Old 05-04-2005   #6
Mr Benn
Members
 
Mr Benn's Avatar
 
Join Date: Oct 2003
Posts: 113
Default

for i in `grep -ir olddirectory/subdir/link1.html /www/vhosts/ | cut -d":" -f1 | sort | uniq`; do cat $i | sed -e 's/olddirectory\/subdir\/link1.html/newdirectory\/newlink1.html/g' > .tmp$$; mv -f .tmp$$ $i; done

That would search all files in /www/vhosts (and all subdirectories) for the string "olddirectory/subdir/link1.html", produce a unique list of filenames with full path, replace the string you searched for with "newdirectory/newlink1.html", write the new output to a temp file, then overwrite the original file with your new one.
__________________
MrBenn

"As if by magic, the shopkeeper appeared."
Mr Benn is offline   Reply With Quote