I would like to use awk on the output of cppcheck - but it seems like cppcheck doesn't output to awk at the end of this one liner put prints to the screen. Is there any way to get the output of cppcheck to only go into the pipe to awk so I can filter it?
git status -s | awk '(($1 ~ /M/) || ($1 ~ /A/)) { print $2 }' | xargs cppcheck -j 2 --enable=warning,performance | awk '/error/ { print $1 }'
And here's my output
[silly.cpp:9]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'char *'.
[silly.cpp:7]: (error) Buffer is accessed out of bounds: buf
It's probably outputing to stderr instead of stdout. Try:
cppcheck ... 2>&1 | awk ...