[root@rsync-41 ~]# result=${test:-UNSET}
[root@rsync-41 ~]# echo $result
UNSET
[root@rsync-41 ~]# test="abc"
[root@rsync-41 ~]# echo $result
UNSET
[root@rsync-41 ~]# result=${test:-UNSET} #通知
[root@rsync-41 ~]# echo $result
abc
[root@web02-7 scripts]# unset result
[root@web02-7 scripts]# unset test
[root@web02-7 scripts]# result=${test:=UNSET}
[root@web02-7 scripts]# echo $result
UNSET
[root@web02-7 scripts]# echo $test #test被顶替
UNSET
[root@web02-7 scripts]# cat UNSET.sh
path=/home/xusx
find ${path-/tmp/} -name "*.tar.gz" -type f |xargs rm -f
[root@web02-7 scripts]# sh -x UNSET.sh
+ path=/home/xusx
+ xargs rm -f
+ find /home/xusx -name '*.tar.gz' -type f
#路径不存在重新指定
[root@web02-7 scripts]# cat UNSET.sh
#path=/home/xusx
find ${path-/tmp/} -name "*.tar.gz" -type f |xargs rm -f
[root@web02-7 scripts]# sh -x UNSET.sh
+ xargs rm -f
+ find /tmp/ -name '*.tar.gz' -type f