#!/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