'How to get all stderr within a for loop?

I want the stderr of all files within a for-loop. So far only the first one in the for loop was written into summary.txt.

My codes:

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


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source