一个很大工程当我们执行make去进行编译的时候,有时会出现 warning;error:undefined情况,高亮这个条目方便我们更好的发现问题
将make产生的 标准错误输出 重定向到/tmp/111文件中,标准输出 输出到终端
make.sh
#!/bin/sh
if [ -z "$1" ]
then
make 2>/tmp/111;
echo -e "\n\033[44mmake \033[0m\n"
else
make $1 2>/tmp/111;
echo -e "\n\033[44mmake $1\033[0m\n"
fi
echo -e "\033[41mwarning:\033[0m\n\033[41m----------------------------\033[0m";
cat /tmp/111|grep -n --color -C 1 " warning: "
echo -e "\033[41m----------------------------\033[0m";
echo -e "\033[44merror:\033[0m\n\033[44m----------------------------\033[0m";
cat /tmp/111|grep -n -P --color -C 1 " error: "
echo -e "\033[44m----------------------------\033[0m";
echo -e "\033[43mundefined reference to:\033[0m\n\033[43m----------------------------\033[0m";
cat /tmp/111|grep -n --color -C 1 " undefined reference to "
echo -e "\033[43m----------------------------\033[0m";
echo -e "\033[46m exit status :\033[0m\n\033[46m----------------------------\033[0m";
cat /tmp/111|grep -n --color -C 1 "exit status"
echo -e "\033[46m----------------------------\033[0m";
结果: