How can I use awk and printf in for loop?
Here is my code
for fileName in /home/BamFiles/sample*
do
sampleIds=${fileName##*/}
for Bam in /home/BamFiles/sample*/*.bam
do
samtools idxstats $Bam | awk '{i+=$3+$4} END {printf("%s\t%d",$sampleIds Bam)}'
done
done
I get the the following error
awk: fatal: not enough arguments to satisfy format string
`%d %s'
^ ran out for this one
Expected output is
sample1 52432
sample2 32909
sample3 54000
sample5 45890
Thanks