samtools depth print out all positions
You might try using bedtools genomecov instead. If you provide the -d option, it reports the coverage at every position in the BAM file.

bedtools genomecov -d -ibam $inputfile &gt; "${inputfile}.genomecov"


You can also provide a BED file if you just want to calculate in the target  region.