Parsing gcc error log

I am currently parsing the error log of gcc like

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 are the line numbers where exactly the errors or warning had occurred. I need to replace these numbers with numbers+10 i.e: 15,18,34,34.

However not every line is a error or warning line.

Answers


I would say awk is a great tool for this job. To apply the change to only the error or warning lines:

$ 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

Need Your Help

Linux-MIPS syscall-saved registers?

c linux assembly mips system-calls

Which registers are saved across syscalls (not function calls, the actual round-trip to kernelspace via the syscall instruction) on Linux/MIPS?

Internal URL rewrite no longer working after upgrading Apache to 2.4

apache .htaccess mod-rewrite

I need to internally rewrite the base URL so that instead of / being mapped to /index.php (default behaviour) it goes to another script named contents.php. I have a simple .htaccess in the doc root:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.