rclone是我从bash脚本运行的备份程序。 我想将此参数传递给rclone:
--exclude "{secret1b,secret1c}/**"
rclone需要那些报价。 这是我失败的尝试:
#!/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)
这很奇怪,因为echo“$ cmd”输出的文字字符串按预期工作。
$(rclone sync /home/wolfv/test_rclone_data/direc1 /home/wolfv/test_rclone_backup/last_snapshot/direc1 --exclude "{secret1b,secret1c}/**")
但命令$ cmd无法按预期工作。
$cmd
有两个类似的问题并没有试图传递引号: