printf "The complete list is %s\n" "$$" 24520 Shell本身的PID
printf "The complete list is %s\n" "$!" 空 Shell最后运行的后台Process的PID
printf "The complete list is %s\n" "$?" 0 最后运行的命令的结束代码(返回值)
printf "The complete list is %s\n" "$*" 123 qq 所有参数列表。如"$*"用「"」括起来的情况、以"$1 $2 … $n"的形式输出所有参数。
printf "The complete list is %s\n" "$@" 123
printf "The complete list is %s\n" "$@" 1 qq 所有参数列表。如"$@"用「"」括起来的情况、以"$1" "$2" … "$n" 的形式输出所有参数
printf "The complete list is %s\n" "$#" 2 添加到Shell的参数个数
printf "The complete list is %s\n" "$0" 1.sh Shell本身的文件名
printf "The complete list is %s\n" "$1" 123 添加到Shell的各参数值。$1是第1参数、$2是第2参数…
printf "The complete list is %s\n" "$2" qq
$@ 里是一个列表
$* 是整体一行字串。
本文详细介绍了Shell脚本中常用特殊变量的功能及应用场景,包括Shell本身的PID、最后运行的后台Process的PID、最后运行命令的返回值等,并解释了如何通过这些变量进行有效的脚本控制和调试。
2137

被折叠的 条评论
为什么被折叠?



