shell 预定义变量

echo "上一次后台pid is $!"
echo "当前进程pid is $$"
echo "last command return code is :$?"
echo "bash file name is $0"
echo "all var is: $*"
echo "var number is : $# "

===========gold  line of out=========

上一次后台pid is
当前进程pid is 53971
last command return code is :0
bash file name is echo_var.sh
all var is: 1 44 test this
var number is : 4

获取脚本name和脚本目录:

basename   filepath 

dirname   filepath 

原文地址:https://www.cnblogs.com/SunshineKimi/p/12291013.html