2
I’m having a problem, I’m making a bash script to run using crontab, which synchronizes my SSD files, with the hard drive and Dropbox.
Script:
#!/bin/bash -
PC_DIR="~/Programming"
DROP_DIR="~/Dropbox/Programação"
PC_FILES="$(find ${PC_DIR} -follow)"
DROP_FILES="$(find ${DROP_DIR} -follow)"
for FILE1 in "${PC_FILES}"
do
echo "FILE1=${FILE1}"
for FILES2 in "${DROP_FILES}"
do
echo "FILE2=${FILE2}"
if [ "${FILE1}" -nt "${FILE2}" ];
then
cp "${FILE1}" "${FILE2}"
elif [ "${FILE1}" -ot ""${FILE2} ];
then
cp "${FILE2}" "${FILE1}"
fi
done
done
The problem with the script is that it treats the "Filex" variables as a large block of text with several line breaking functions (' n') ex:
FILE1=~/Programming
~/Programming/C++
~/Programming/C++/teste.cpp
~/Programming/C++/test.cpp
Pórem, to do the tests of 'Newerthan' and 'Olderthan', I need to be able to look at each line as a different directory, and not as a big block, how can I do this?
Gabriel, watch the remote
rsync
inside the machine or remote plant. Example:rsync -l -turv dir/ maquina.remota:dir/
– JJoao
Gabriel, it seems to me that your algorithm copies the newest file onto everyone else...
– JJoao