Here you go. Run with
% fixFiles <directory to fix>
and tailor the paths inside the script (or turn them into arguments).
cheers
Neil
#!/bin/bash
oldPath="/store/projects"
oldPath2="\/store\/projects"
#
newPath2="\/store2\/newprojects"
# Find all files
find $1 -type f | while read file ; do
# See if the file is ASCII
ft=`file $file`
if [[ $ft = *ASCII* ]]; then
# Look for known path
y=`grep $oldPath $file`
if [ "$y" ]; then
# Replace path
echo "Fixing " $file
sed -i "s/$oldPath2/$newPath2/g" $file # Double quote to translate variables
fi
fi
done
|