shell脚本之接受终端输入参数

linux

 

#!/bin/bash
echo "shell param:"
echo "file name:$0"
echo "first param:$1"
echo "second param:$2"
echo "third param:$3"
echo "fourth param:$4"
echo "five param:$5"
echo "param num:$#"
echo "param as a string:$*"
echo "show every param"
for i in "$*";do
        echo $i
done

echo "show every param"
for i in "$@";do
        echo $i
done


输出结果

[root@MiWiFi-R3P-srv day2]# sh param.sh 1 2 3 4 5 6 7
shell param:
file name:param.sh
first param:1
second param:2
third param:3
fourth param:4
five param:5
param num:7
param as a string:1 2 3 4 5 6 7
show every param
1 2 3 4 5 6 7
show every param
1
2
3
4
5
6
7


如果发现下载不了或者地址失效,请联系客服QQ: 2323178881
找资料 » shell脚本之接受终端输入参数

提供最优质的资源集合

立即查看 了解详情