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.
我正在尝试转发收集到的所有选项,以便在 shell 脚本中的另一个命令中使用。
例如,如果脚本运行如下:
./master -o -t -k Arg1
在主
.:o.:t.:k.:r
./slave -o -t -k Arg2
我希望使用所有 ( -o -t -k) 或任何其他选项组合条目 - 我该怎么做?
-o -t -k
你可以做到./slave ${*/Arg1/Arg2}。这将在替换为之后将所有参数从 发送master到。好的是将所有输入评估为一个字符串(与 不同),允许进行简单的替换。slaveArg1Arg2$*$@
./slave ${*/Arg1/Arg2}
master
slave
Arg1
Arg2
$*
$@