从gcc / g ++编译结果中删除文件名

时间:2013-01-19 18:41:27

标签: regex linux gcc g++

我想从gcc / g ++编译错误消息中删除文件名。

当我运行gcc myfolder/temp.c时,结果为:

myfolder/temp.c:5:1: error: unknown type name ‘voi’
myfolder/temp.c:87:6: error: conflicting types for ‘max’
myfolder/temp.c:5:5: note: previous declaration of ‘max’ was here

但我想要这个:

5:1: error: unknown type name ‘voi’
87:6: error: conflicting types for ‘max’
5:5: note: previous declaration of ‘max’ was here

那是否有gcc标志?

1 个答案:

答案 0 :(得分:3)

我怀疑有一个选项,但您可以使用标准实用程序获得相同的结果。例如cut(1)

 gcc -c myfolder/temp.c 2>&1 | cut -d: -f2-