- $0: shell脚本名
- $1: 执行shell脚本传的第一个参数, $n, 第n个参数
- $?: 上一条命令的执行状态,0为成功
- $*: 执行shell脚本传的所有参数
- $@: 同上
- $$: 所在命令的PID
test.sh
#!/bin/sh
echo "hello"
echo "filename:$0"
echo "last result:$?"
echo "all parameters:$*"
echo "all parameters:$@"
echo "count parameters:$#"
echo "pid:$$"
echo "first para:$1"
echo "second para:$2"
修改文件权限:所有用户添加执行权限
chmod a+x test.sh
执行shell脚本
./test.sh 1 “para2”
hello
filename:./test.sh
last result:0
all parameters:1 para2
all parameters:1 para2
count parameters:2
pid:214
first para:1
second para:para2