Hi Tom,
Splitting BAM file was one possible way to go. I had to change it a bit to get output in compressed BAM. Here is an example what worked for me to generate 27 nt bam.
samtools view -h my.bam | awk 'BEGIN {FS="\t"}; ((/^@/) || (length($10) == 27)) {print $0}' | samtools view -bS - > my_27.bam
I was wondering is there any options to do the same without creating additional intermediate files.