码迷,mamicode.com
首页 > 系统相关 > 详细

shell args (1)

时间:2019-01-24 14:35:23      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:$?   $$   bin   one   user   done   name   dem   echo   

$ cat test.sh
#!/bin/bash

echo "shell args option"
echo "script name : $0"
echo "first args : $1"
echo "first args : $2"
echo "first args : $3"

echo "------- \$# demonstration"
echo "args number: $#"


echo "------- \$\$ demonstration"
echo "shell pid: $$"

echo "------- \$* demonstration"
for i in "$*";do
echo $i
done

echo "------- \$@ demonstration"
for i in "$@";do
echo $i
done

echo "------- \$- demonstration"
echo $-

 

$ ./test.sh 1 2 3
shell args option
script name : ./test.sh
first args : 1
first args : 2
first args : 3
------- $# demonstration
args number: 3
------- $$ demonstration
shell pid: 12263
------- $* demonstration
1 2 3
------- $@ demonstration
1
2
3
------- $- demonstration
hB
vmuser@vmuser-virtual-machine:~/shell$ echo $?
0

shell args (1)

标签:$?   $$   bin   one   user   done   name   dem   echo   

原文地址:https://www.cnblogs.com/lianghong881018/p/10314026.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!