I am trying to loop paired end reads in hisat2 with an output of sorted bam using a pipe. 

I am a novice at coding but am keen to improve my skills by learning how to loop. 

I have created this loop using the answers from https://www.biostars.org/p/223404/ 

   

     for f in `ls *.fastq.gz | sed 's/_[12].fastq.gz//g' | sort -u`
    do
    echo hisat2 -x /mnt/z/NathanHaffordTear/RNAseqproject/RNAseqanalysis/hg38_index -1 ${f}_1.fastq.gz -2 ${f}_2.fastq.gz | samtools sort -o ${f}.hisat.sorted.bam
    done

For some reason the loop does work without the pipe but not with. How can i configure this loop to work with the piping as I do not want to have the intermediate files?

Many thanks in advance
Remove the `echo` as you want to execute rather than print the command.
If you want "status updates" do

    echo $f && hisat2 (...)