某些命令输出不能直接写入管道进行处理,例如
python -v需要重定向输出之后才能进行处理
python -V 2>&1|cut -d' ' -f2
ttt=`gcc 2>&1|grep 'not found'`
if [ $ttt=="" ];then
echo "gcc 已安装"
else
echo "安装gcc"
unzip gccrpm.zip
cd gccrpm
rpm -Uvh *.rpm --nodeps --force
cd ..
fi
mip=`ifconfig|grep 'inet addr:'| grep -v '127.0.0.1'|cut -d: -f2 | awk '{ print $1}'`
echo "mip:$mip"