您的位置:首页 > 运维架构 > Shell

shell 命令结果无法处理

2016-09-06 19:27 211 查看
某些命令输出不能直接写入管道进行处理,例如

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"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: