shellScript之位置参数

#!/bin/bash

echo "The script name is:$0"
echo "Paramter #1 is:$1"
echo "Paramter #2 is:$2" 
echo "Paramter #3 is:$3"
echo "Paramter #4 is:$4"
echo "Paramter #5 is:$5" 
echo "Paramter #6 is:$6" 
echo "Paramter #7 is:$7" 
echo "Paramter #8 is:$8"
echo "Paramter #9 is:$9"
echo "Paramter #10 is:$10"
echo "Paramter #11 is:$11" 

echo "ALL the command line paramter are:$*"
echo "how many command are there:$#"

echo "all the command line paramter are:$@"
echo "the pid of the script is:$$"
echo "the return value is :$?"


位置参数示例如上,注意三个变量的使用:$* 传递到脚本的所有参数   

                                                                         $@ 传递到脚本的所有参数

                                                                       $$  脚本的运行id号

                                                                       $?  脚本的返回值

结果:

~/shell_text $ ./1position_var.sh 1 2 3 4 5 6 7 8 9 10 11
The script name is:./1position_var.sh
Paramter #1 is:1
Paramter #2 is:2
Paramter #3 is:3
Paramter #4 is:4
Paramter #5 is:5
Paramter #6 is:6
Paramter #7 is:7
Paramter #8 is:8
Paramter #9 is:9
Paramter #10 is:10
Paramter #11 is:11
ALL the command line paramter are:1 2 3 4 5 6 7 8 9 10 11
how many command are there:11
all the command line paramter are:1 2 3 4 5 6 7 8 9 10 11
the pid of the script is:3816
the return value is :0


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值