我想将给脚本的命令行参数传递给另一个命令,但我也想先在前面添加一些额外的参数。我怎样才能用 bash 做到这一点?
这会将所有参数发送到命令:
command $@
但我想要更像:
command [argument1, argument2, $@]
你怎么能在 bash 中做这样的事情?
最佳答案
@ThatOtherGuy 的回答是正确的。
如果您希望将几个参数“取消移位”到位置参数中,请执行以下操作:
set -- arg1 arg2 "$@"
cmd "$@"
关于linux - 在 linux/bash 中添加命令行参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21790556/