I have this shell script
#!/bin/sh
PATHS=( a b c d )
for PATH in ${PATHS[@]}
do
rsync -avziP /home/user/$PATH $SERVER:$server_folder -b --backup-dir=$backup_folder/backup_$date --delete --exclude=.* --log-file=$HOME/rsync.log
done
And I always get this error:
rsync: command not found
What is driving me crazy is that if I delete the for loop, and just run the rsync command, the script works perfectly
PATHis a reserved variable!It is the variable specifying where to search tools (like
rsync)Use another variable name!
Avoid upper case in script variable names:
And keep habit of enclosing your variable in double quotes when used as argument!