samflags
Decode SAM flags into English using the command-line
samfilter
These two tools allow the counting of alignment flags (https://broadinstitute.github.io/picard/explain-flags.html) in a SAM formated file and the extraction of reads for selected flags.