1

How can I pass a variable onto a command's parameter in a bash script?

view story
linux-howto

http://stackoverflow.com – Example bash script demonstrating my problem: #!/bin/bash function exclude { BACKUP_EXCLUDES="$BACKUP_EXCLUDES --exclude=\"$1\"" } exclude "/proc" exclude "/dev" exclude "/mnt" exclude "/media" exclude "/lost+found" echo $BACKUP_EXCLUDES Output: --exclude="/proc" --exclude="/dev" --exclude="/mnt" --exclude="/media" --exclude="/lost+found" Perfect! But when I try adding: rsync -ruvz $BACKUP_EXCLUDES / /some/backup/path $BACKUP_EXCLUDES is completely ignored with no errors or warnings... Why? (HowTos)