我如何转发在bash脚本参数等命令? [英] How do I forward parameters to other command in bash script?
本文介绍了我如何转发在bash脚本参数等命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的bash脚本,我想解析零,一个或两个参数(脚本可以识别它们)。
随后的参数命令向前休息脚本调用。怎么办呢?
Inside my bash script, I would like to parse zero, one or two parameters (script can recognize them). Then forward rest of parameters to a command invoked in the script. How to do it?
推荐答案
使用的 移
内置命令吃的论点。然后调用子进程,并将它传递的 $ @
参数,包括所有剩余的参数。注意引号,他们应该被保留,因为它们所造成的参数列表的扩展被正确引用。
Use the shift
built-in command to "eat" the arguments. Then call the child process and pass it the "$@"
argument to include all remaining arguments. Notice the quotes, they should be kept, since they cause the expansion of the argument list to be properly quoted.
这篇关于我如何转发在bash脚本参数等命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文