2013-08-02 156 views
0

我目前解析的gcc錯誤日誌就像解析GCC錯誤日誌

main.c:5:1: warning: data definition has no type or storage class [enabled by default] 
main.c:8:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’ 
main.c in function 'TryAdddition()' 
main.c:24:1: warning: data definition has no type or storage class [enabled by default] 
main.c:24:10: warning: data definition has no type or storage class [enabled by default] 

5,8,24,24都曾經發生完全錯誤或警告的行號。 我需要用數字+ 10 替換這些數字,例如:15,18,34,34

但不是每一行都是錯誤或警告行。

+0

這個問題似乎是題外話,因爲它是在這裏交叉貼:http://unix.stackexchange.com/questions/36949/addition-與-SID –

回答

5

我會說awk是一個偉大的工具,這項工作。爲了將更改應用於僅errorwarning線:

$ awk '$4==" warning" || $4==" error"{$2+=10}1' FS=':' OFS=':' file 
main.c:15:1: warning: data definition has no type or storage class [enabled by default] 
main.c:18:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’ 
main.c in function 'TryAdddition()' 
main.c:34:1: warning: data definition has no type or storage class [enabled by default] 
main.c:34:10: warning: data definition has no type or storage class [enabled by default