我有一个case命令,它有几个选项,其中一个是失败的存储空间大小。
#################### System Information Tests ##############################
export HOME=`cd;pwd`
export Storage_Space_Size=$(df -h --output=avail ${HOME} | awk 'NR==2 {print $1}' | tr -cd '[:digit:]')
export Storage_Space_Units=$(df -h --output=avail ${HOME} | awk 'NR==2 {print $1}' | tr -cd '[:alpha:]')
export Storage_Space_Required="350"
echo " Testing for Storage Space for installation"
echo " "
case $Storage_Space_Units in
[Pp]* )
echo "Sufficient storage space for installation found" ;;
[Tt]* )
echo "Sufficient storage space for installation found" ;;
[Gg]* )
if [[ ${Storage_Space_Size} -lt ${Storage_Space_Required} ]]; then
echo "Not enough storage space for installation"
else echo "Sufficient storage space for installation found."
fi ;;
[MmKk]* )
echo "Not enough storage space for installation."
exec $SHELL ;;
* )
echo "Not enough storage space for installation."
exec $SHELL ;;
esac
echo " "
exec $SHELL是退出脚本的最佳方法还是有其他方法?
退出脚本而不保留失败环境的替代方法
1条答案
按热度按时间oipij1gg1#