Page 1 of 1
Global Find Replace Whole Directory
Posted: Thu Aug 03, 2006 6:55 am
by Ollie Saunders
I want to find and replace a string for another in a whole directory of files. Pretty simple really.
I have access to PHP, linux commands and Windows software.
Any simple suggestions?
Posted: Thu Aug 03, 2006 6:58 am
by Oren
Sorry, I don't get what you want. Can you be more specific please?
Posted: Thu Aug 03, 2006 7:28 am
by Ollie Saunders
I have 30 PHP files in a directory.
I want to find all instances of 'OsisForm' within the files and replace it with 'OF'
Posted: Thu Aug 03, 2006 7:31 am
by Benjamin
Be sure to chmod a+x it..
replace.sh
Code: Select all
for fl in *.php; do
mv $fl $fl.old
sed 's/OsisForm/OF/g' $fl.old > $fl
#rm -f $fl.old
done
Posted: Thu Aug 03, 2006 8:24 am
by Ollie Saunders
worked a treat astions.
thanks.