Samtools can be used to select reads above certain mapping quality. 

    samtools view -h -b -q 30 aligned.bam -o above.mapQ30.bam

**But, how to select a read below certain mapping quality - all aligned reads below mapQ 30?**

I know it can be done using awk. But, the pipeline gets lengthy and time consuming when first need to convert bam to sam - separate header - use awk for mapQ below 30 - add header - sam file - convert to bam.
Really, its taking a lots of time.

Thanks,


Use SAMtools with the -U flag to output reads that don't match your filter, e.g.

> samtools view -h -b -q 30 -U below_q30.bam aligned.bam