This is a small optimization suggestion. There is no need to use cat to pipe head since head can read the file and stop when reaching the number of lines.
I tested this with a 24GB file, and this are the results:
$ time head -n 4000000 file.fastq > tmp.fastq
real 0m0.388s
user 0m0.252s
sys 0m0.136s
$ time cat file.fastq | head -n 4000000 > tmp2.fastq
real 0m0.426s
user 0m0.240s
sys 0m0.361s
$ diff tmp.fastq tmp2.fastq
At the same time this avoids using pipe and throwing a cat: write error: Broken pipe error.
This is a small optimization suggestion. There is no need to use
cat
to pipehead
sincehead
can read the file and stop when reaching the number of lines.I tested this with a 24GB file, and this are the results:
At the same time this avoids using pipe and throwing a
cat: write error: Broken pipe
error.