如何给shell脚本传参数
1个回答
展开全部
看最简单的脚本b1.sh:
$ cat b1.sh
#!/bin/bash
echo "I am, you are"
运行b1.sh:
$ b1.sh (或者运行./b1.sh)
I am, you are
脚本b2.sh有参数$1, $2:
$ cat b2.sh
#!/bin/bash
echo "I am $1, you are $2"
运行b2.sh
$ b2.sh (或者运行./b2.sh)
I am , you are
运行带参数的脚本b2.sh
$ b2.sh Jack Mike
I am Jack, you are Mike
现在清楚了吧。
$ cat b1.sh
#!/bin/bash
echo "I am, you are"
运行b1.sh:
$ b1.sh (或者运行./b1.sh)
I am, you are
脚本b2.sh有参数$1, $2:
$ cat b2.sh
#!/bin/bash
echo "I am $1, you are $2"
运行b2.sh
$ b2.sh (或者运行./b2.sh)
I am , you are
运行带参数的脚本b2.sh
$ b2.sh Jack Mike
I am Jack, you are Mike
现在清楚了吧。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询