1 # $0 -> 命令本身
2
3 # $1 -> 第一个参数
4
5 # $# -> 参数个数
6
7 # $* -> 所有参数,按一个字符串操作
8
9 # $@ -> 所有参数,按单个字符串操作
10
11 # $$-> 当前PID
1 [22:43:12 root@centos8 test]#bash /data/arg.sh {a..z}
2 1st arg is a
3 2nd arg is b
4 3rd arg is c
5 10st arg is j
6 all args are a b c d e f g h i j k l m n o p q r s t u v w x y z
7 all args are a b c d e f g h i j k l m n o p q r s t u v w x y z
8 the script name is arg.sh
9 [22:43:26 root@centos8 test]#cat /data/arg.sh
10 #!/bin/bash
11 #
12 #**************************************************************************************
13 #Author: Noise Lys
14 #QQ: 578110218
15 #Date: 2021-06-03
16 #Filename: arg.sh
17 #URL: https://www.cnblogs.com/noise/
18 #Description: The test script
19 #Copyright (C): 2021 All rights reserved
20 #**************************************************************************************
21 echo "1st arg is $1"
22 echo "2nd arg is $2"
23 echo "3rd arg is $3"
24 echo "10st arg is ${10}"
25 echo "all args are $*"
26 echo "all args are $@"
27 echo "the script name is `basename $0`"