qfedu-linux-advanced-level/day1/d11.sh

22 lines
388 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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