Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想--exclude通过变量扩展 tar 参数,例如:
--exclude
set -x verbose EXC=AAA,BBB echo --exclude={$EXC} > /dev/null
输出: echo '--exclude={AAA,BBB}'
echo '--exclude={AAA,BBB}'
但我期望: echo --exclude=AAA --exclude=BBB
echo --exclude=AAA --exclude=BBB
我尝试了不同的调用,但什么都没有……怎么了?
替换变量后需要使用eval解析行。
eval
eval "echo --exclude={$EXC}"