I'm trying to put the amount of lines in a gzipped file in a variable, later on I plan to use this stdout for another process using tee. Why won't the value of wc -l get put into the variable and how can I fix this?
[]$ gzip -dc BC102.fastq.gz | wc -l
4255588
[]$ gzip -dc BC102.fastq.gz | echo $(wc -l)
4255588
[]$ gzip -dc BC102.fastq.gz | reads=$(wc -l); echo $reads
0
The whole line is eventually supposed to look like
gzip -dc BC102.fastq.gz | tee >(reads=$(wc -l)) | cutadapt -ga...
I don't see how this is a duplicate from How to set a variable to the output from a command in Bash? since I was already applying the answer listed there to echo the value of wc -l directly, but it won't be inserted into the variable.