关闭

Shell Script中$0等表示的含义

772人阅读 评论(0) 收藏 举报
分类:
#!/bin/bash
#Program:
#    Program shows the script name, parameters
#History:
#    2013/08/26
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

echo "The script name is    ==> $0"
echo "Total parameter number is ==> $#"
[ "$#" -lt 2 ]  && echo "The number of parameter is less than 2. Stop here." \
    && exit 0
echo "Your whole parameter is ==>$@"
echo "the 1st parameter   ==> $1"
echo "the 2nd parameter  ==>$2"


#!/bin/bash
#Program:
#    Program shows effect of shift function
#History:
#    2013/08/26
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

echo "Total parameter number is ==> $#"
echo "Your whole parameter is ==>$@"
shift #进行第一次“一个变量的shift”
echo "Total parameter number is ==> $#"
echo "Your whole parameter is ==>$@"
shift 3 #进行第一次“一个变量的shift”
echo "Total parameter number is ==> $#"
echo "Your whole parameter is ==>$@"


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:65181次
    • 积分:1619
    • 等级:
    • 排名:千里之外
    • 原创:93篇
    • 转载:54篇
    • 译文:1篇
    • 评论:3条
    最新评论