22 lines
388 B
Bash
22 lines
388 B
Bash
|
#!/bin/bash
|
|||
|
|
|||
|
# $# 用于获取参数的个数
|
|||
|
echo "$#"
|
|||
|
# $* 用于获取所有参数
|
|||
|
echo "$*"
|
|||
|
# $1 $2 $3 用于获取第 1 2 3 个参数
|
|||
|
echo "$1,$2,$3"
|
|||
|
|
|||
|
# $? 用于获取上一条命令的返回值,0 为正确,非 0 为错误
|
|||
|
echo $?
|
|||
|
rm a.txt
|
|||
|
echo $?
|
|||
|
|
|||
|
# $$ 用于获取当前脚本的进程号
|
|||
|
echo $$
|
|||
|
# $0 用于获取当前脚本的名称
|
|||
|
echo $0
|
|||
|
|
|||
|
|
|||
|
|
|||
|
# 测试使用 ./d11.sh 1 2 3
|