#!/bin/bash

for i in *.te.Aligned.sortedByCoord.out.bam; do (
        filename=${i%%.te.Aligned.sortedByCoord.out.bam}
        samtools view -f 0x10 -b $i > $filename.0.bam;
        samtools index $filename.0.bam;
        samtools idxstats $filename.0.bam | cut -f 1,3 > $filename.0.te.chrom_reads.txt;
        ) &
done

exit