Skip to content

Instantly share code, notes, and snippets.

@r-k-b
Last active April 3, 2019 03:23
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 r-k-b/92301be41b32f32b971b8d386be534ca to your computer and use it in GitHub Desktop.
Save r-k-b/92301be41b32f32b971b8d386be534ca to your computer and use it in GitHub Desktop.
one-liner to extract & count the types of warnings from a c# build
cat build-output.txt | sed -rn 's/^.*\[([A-Z]+[0-9]+)\].*$/\1/p' | sort | uniq -c | sort -nr

Explanation:

                       ↑                                           ↑      ↑         ↑
                       a                                           b      c         d

a

Extracts the warning code (like CS1234 from foo [CS1234]: bar), discarding the rest of the line (and all non-matching lines)

b

sort all codes, so uniq works as intended

c

counts unique occurrences for each code

d

sorts by most-common-first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment