rclone is a backup program I run from a bash script. I want to pass in this parameter to rclone:
--exclude "{secret1b,secret1c}/**"
rclone needs those quotes. Here is my failed attempt:
#!/bin/bash
cmd='rclone sync /home/wolfv/test_rclone_data/direc1 /home/wolfv/test_rclone_backup/last_snapshot/direc1 --exclude "{secret1b,secret1c}/**"'
printf "command: \n$cmd\n\n"
echo "$cmd"
#echo and printf output as expected:
#rclone sync /home/wolfv/test_rclone_data/direc1 /home/wolfv/test_rclone_backup/last_snapshot/direc1 --exclude "{secret1b,secret1c}/**"
#rclone with --exclude works as expected:
$(rclone sync /home/wolfv/test_rclone_data/direc1 /home/wolfv/test_rclone_backup/last_snapshot/direc1 --exclude "{secret1b,secret1c}/**")
#on these $cmd, rclone works but the --exclude is not excluding:
$cmd
$($cmd)
It's weird because the literal string output by echo "$cmd" works as expected.
$(rclone sync /home/wolfv/test_rclone_data/direc1 /home/wolfv/test_rclone_backup/last_snapshot/direc1 --exclude "{secret1b,secret1c}/**")
But the command $cmd does not work as expected.
$cmd
There are two similar questions that are NOT trying to pass in the quotes: