如何在 for 循环中获取所有 stderr?

How to get all stderr within a for loop?

我想要一个 for 循环中所有文件的 stderr。至此for循环中只有第一个被写入了summary.txt.

我的代码:

SAMPLES="SRR1 SRR2 SRR3 SRR4"
    
 for SAMPLE in $SAMPLES; do hisat2 -p 24 -x /home/genome_g7b -1   /home/${SAMPLE}_1_val_1.fq -2 /home/${SAMPLE}_1_val_2.fq -S ${SAMPLE}.sam | 2>summary.txt

done

您为循环内的所有命令重定向了文件描述符

for anything in anything; do
    anything
done 2>summary.txt