Skip to content

Instantly share code, notes, and snippets.

@patrickelectric
Forked from zbyhoo/count_gcc_warnings.sh
Created May 10, 2018 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickelectric/b333936746a1299b149a34b779706c5c to your computer and use it in GitHub Desktop.
Save patrickelectric/b333936746a1299b149a34b779706c5c to your computer and use it in GitHub Desktop.
Sorts and counts all warnings from gcc compilation output
#!/bin/bash
if [ "$#" != "1" ]
then
echo wrong number of arguments
echo Usage: $0 \<filename\>
echo filename - file with build output
exit 1
else
cat $1 | grep "warning:" | sort | uniq -c | sort -nr | awk '{print $0}{total+=1}END{print "Total number of warnings:\n"total}'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment