shell 脚本判断linux版本型号
awk -F= '/^NAME/{print $2}' /etc/os-release
centos输出结果
"CentOS Linux"
ubuntu输出结果
"Ubuntu"
============================================
if循环
if [ command ];then
符合该条件执行的语句
elif [ command ];then
符合该条件执行的语句
else
符合该条件执行的语句
fi
=============================================
命令结果=函数
hardDisk=`df -h |grep -w '/'|awk '{ print $5}'| tr -d %`
=============================================
判断一条命令是否有输出
info=`
ls
/dev/mapper/isw_
*`
if
[ -z
"$info"
];
then
echo
"find no fake raid"
else
echo
"yes, find result is $info"
fi
-z判断为空,-n判断是非空