nested if: too many arguments?
- by FLX
For some reason this code creates problems:
source="/foo/bar/"
destination="/home/oni/"
if [ -d $source ]; then
echo "Source directory exists"
if [ -d $destination ]; then
echo "Destination directory exists"
rsync -raz --delete --ignore-existing --ignore-times --size-only --stats --progress $source $destination
chmod -R 0755 $destination
else
echo "Destination directory does not exists"
fi
else
echo "Source directory does not exists"
fi
It errors out with:
Source directory exists
/usr/bin/copyfoo: line 7: [: too many arguments
Destination directory does not exists
I used nested if statements in bash before without a problem, what simple mistake am I overlooking?
Thanks!