1

我想在 cppcheck 的输出上使用 awk - 但似乎 cppcheck 在这一行的末尾没有输出到 awk 将打印到屏幕上。有没有办法让 cppcheck 的输出只进入到 awk 的管道中,以便我可以过滤它?

git status -s | awk '(($1 ~ /M/) || ($1 ~ /A/)) { print $2 }' | xargs cppcheck -j 2 --enable=warning,performance | awk '/error/ { print $1 }'

这是我的输出

[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
4

1 回答 1

2

它可能输出到标准错误而不是标准输出。尝试:

cppcheck ... 2>&1 | awk ...
于 2015-01-24T15:30:19.300 回答