On Fri, Dec 06, 2024 at 15:11:51 -0700, pe...@easthope.ca wrote: > (2) > exclusions='*.mp3' > exclusions+='*.mp4' > Restore() { \ > source=somewhere/Backup/ ; > echo "source is $source." ; > destination=elsewhere/workingDirectory ; > echo "destination is $destination." ; > rsync \ > -anuv --exclude=$exclusions $source $destination ; } > > In a realistic case, there are more than two exclusion patterns.
Store the exclusions in an ARRAY, not in a string. Then create a second array which contains the spelled-out --exclude=... options. #!/bin/bash exclusions=( '*.mp3' '*.mp4' '*.wav' ) exclude=( "${exclusions[@]/#/--exclude=}" ) source=... destination=... rsync -anuv "${exclude[@]}" "$source" "$destination"