我希望在 awk 的每一行上打印 $fname 的以下输出:
for fname in $(ls *.bam | cut -c -9 | uniq)
do
echo $fname
samtools depth -a "$fname".bam | awk '{sum+=$3} END {print "Average = ", sum/NR}' >> mean.depth
done
电流输出:
$ less mean.depth
Average = 5.40089
Average = 4.68387
期望的输出:
$ less mean.depth
FILENAME1 Average = 5.40089
FILENAME2 Average = 4.68387
这样输出的平均深度是可追溯的。我已经尝试了 FILENAME 和各种各样的东西,但没有成功。谢谢!