Hi all
I have a bash script, that loops through a folders files and all subfolders for .shtml files.
It looks for a string and replaces it, creating a backup of the original file.
This all works great, but I'd like, when the backup is done, that the files are then also created in their respective folders.
So if example.shtml is found in /var/www/files/example/example.shtml
And the backup folder is /var/www/files/backup
Then the file should be in /var/www/files/backup/example/example.shtml
My current code is:
PHP Code:
#!bin/bash
OLD="This is a"
NEW="I am a"
BPATH="../backup"
find . -name '*.shtml' -type f |
while read filename
do
/bin/cp -f $filename $BPATH
sed -i "s/$OLD/$NEW/g" $filename
done
All help muchly welcome
Regards