从shell脚本向Java传递第二个参数 [英] Passing second argument onwards from a shell script to Java

查看:78
本文介绍了从shell脚本向Java传递第二个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果将任意数量的参数传递给内部调用Java程序的shell脚本,那么除了第一个参数外,如何将第二个参数传递给Java程序?

If I pass any number of arguments to a shell script that invokes a Java program internally, how can I pass second argument onwards to the Java program except the first?

./my_script.sh a b c d ....

./my_script.sh a b c d ....

#my_script.sh
...
java MyApp b c d ...

推荐答案

首先使用 shift 来消费"第一个参数,然后传递"$ @" ,即,剩余参数列表:

First use shift to "consume" the first argument, then pass "$@", i.e., the list of remaining arguments:

#my_script.sh
...
shift
java MyApp "$@"

这篇关于从shell脚本向Java传递第二个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆