I've been searching all over the web for a .sh script to do this but i didn't find any.
In this moment i have a script that will create a file list with the find command. This file list is used with copy to replicate them on another folder and everything works well.
Now i want to create a script file that will take the file list and perform the following test: - If the file doesn't exist on destination, copy the file. - If the file exists on the destination and it's the same of the source, don't do anyhing. - If the file exists on the destination and it's different from the source, copy it and change it's extension to .new
This is the script that will create the file list:
# File source to copy text files
find /home/repo/source -type f -name '*.txt' -o -name '*.cfg' -o -name '*.doc' -o -name '*.lst' -o -name '*.inf' -o -name '*.xml' > ../copy-from.txt
sed -i 's/ /\\ /g' ../copy-from.txt
# File destination to copy text files
find . -type f -name '*.txt' -o -name '*.cfg' -o -name '*.doc' -o -name '*.lst' -o -name '*.inf' -o -name '*.xml' > ../copy-to.txt
sed -i 's/ /\\ /g' ../copy-to.txt
sed -i 's/\(.\{2\}\)//' ../copy-to.txt
# Merge source and destination files and add cp command
paste ../copy-from.txt ../copy-to.txt > ../copy.sh
rm ../copy-from.txt ../copy-to.txt
sed -i 's/^/cp /' ../copy.sh
Hope someone can point me to the right path or provide a script that will do what i am looking for.
Regards
Aucun commentaire:
Enregistrer un commentaire