标签:style blog http color io ar for sp log
shell的命令行参数
-bash-4.2$ cat test1.sh
#!/bin/sh
echo "$0 "
echo "$1 "
echo "$2 "
-bash-4.2$ ./test1.sh a b c
./test1.sh
a
b
-bash-4.2$
显示所有命令行参数
-bash-4.2$ cat test1.sh
#!/bin/sh
until [ -z "$1" ]
do
echo "$1 "
shift
done
-bash-4.2$ ./test1.sh a b c d e f
a
b
c
d
e
f
-bash-4.2$ cat test1.sh
#!/bin/sh
index=1
for myarg in $*
do
echo "NO#$index=$myarg"
let "index+=1"
done
-bash-4.2$ ./test1.sh a b c d e f
NO#1=a
NO#2=b
NO#3=c
NO#4=d
NO#5=e
NO#6=f
-bash-4.2$
标签:style blog http color io ar for sp log
原文地址:http://blog.csdn.net/myhaspl/article/details/39394685