I have the following for-loop which loops through all the given sources that need to be copied.
for i in "${sources[@]}"; do
exclude="--exclude 'exclude_folder/exclude_file'"
rsync -az $exclude $i $destination
done
However, the exclude option is not working.
for i in "${sources[@]}"; do
exclude="--exclude 'exclude_folder/exclude_file'"
rsync -az "$exclude" "$i" "$destination"
done
If I use the code above, rsync will exit and give an error that it is an unknown option.
If I simply use the following code, it works, but I want to use a variable for the exclude option.
for i in "${sources[@]}"; do
rsync -az --exclude 'exclude_folder/exclude_file' $i $destination
done