如何获得第i个输入参数? [英] How to get the ith input argument?
本文介绍了如何获得第i个输入参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获取第ith个输入参数,例如:
./test.sh什么是"在哪里"如何"何时"
假设我要回显第二个变量的值,则应打印"where is"
如果变量中没有空格,则使用$ @ $ *可以轻松解决此问题,但是我不知道现在如何执行此操作..
..
没关系,我知道了.
像
这样执行命令
用于arg
echo $ arg ....
不聪明...
I want to get the ith input argument such that:
./test.sh "what is" "where is" "how" "when"
Say if I want echo the value of the 2nd variable, it should print "where is"
If there is no blank in variable, using $@ $* can easily handle the problem, but I have no idea how to do this now..
..
Never mind, I figure it out..
just do command like
for arg
echo $arg....
Not smart...
推荐答案
@
*可以轻松解决此问题,但是我不知道该怎么做现在..
..
没关系,我知道了.
像
做命令
用于arg
echo
* can easily handle the problem, but I have no idea how to do this now..
..
Never mind, I figure it out..
just do command like
for arg
echo
arg ....
不聪明...
arg....
Not smart...
这篇关于如何获得第i个输入参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文