1.几个特殊变量
$$:获取当前执行shell的pid
$?:返回上一条命令的返回值,或者方法的返回值;
$!:返回上一条命令的pid
2.字符串的截取
names[0]="liu.jar|first";
names[1]="jian.jar|second";
for index in ${names[*]}
do
s=${index%%|*}
h=${index##*|}
echo "截取前半部分:${s}"
echo "截取后后半部分:${h}"
done
结果:
liu first
jian second
3.判空处理
#t=""
t=
if [ -z "${t}" ]
then
echo "wu zhi ${#t}"
else
echo "you zhi${#t} "
fi
结果:当t=;或者t=""均为wuzhi 0
当t=123;结果为youzhi 3