I'm having a problem, I'm doing a bash script to run using crontab, which syncs my ssd files with the hd 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 break functions ('\ n') eg:
FILE1=~/Programming
~/Programming/C++
~/Programming/C++/teste.cpp
~/Programming/C++/test.cpp
In order to do the 'NewerThan' and 'OlderThan' tests, I need to be able to look at each line as a different directory, not as a big block,