开发者

run unison in bash script

Hi when I run a command on terminal like that

unison dir1 dir2 -ignore 'Regex dir3' -batch -force dir1 -confirmbigdel=false

it runs normally. But when I try to run it in a bash script it like that

a="-ignore 'Regex dir3'"
unison dir1 dir2 "$a" -batch -force dir1 -confirmbigdel=false

it says that

unison: unknown option `-ignore 'Regex c''

开发者_Go百科

How can I solve that problem? Thank you... .


You need to use an array instead of a string. That way, when you "dereference", the shell will see the right number of words (2).

a=( -ignore 'Regex dir3' )
unison dir1 dir2 "${a[@]}" -batch -force dir1 -confirmbigdel=false
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜