All protocols

Count the number of reads in a FASTQ file

A one-liner to count sequencing reads in a FASTQ file, why it works, and how to handle gzipped input.

SSSudipta SardarUpdated July 8, 2026

Prerequisites

  • A terminal with bash
  • A FASTQ file (optionally gzipped)

1Count lines and divide by four

Each read in a FASTQ file occupies exactly four lines. Count the lines and divide by four.

bash
echo $(($(wc -l < reads.fastq) / 4))

Expected output

1000000

2Handle gzipped FASTQ

If the file is gzipped, stream it through zcat first so you never decompress to disk.

bash
echo $(($(zcat reads.fastq.gz | wc -l) / 4))

Expected output

1000000

Troubleshooting

wc -l returns a number not divisible by 4

The file is likely truncated or corrupted. Re-download and verify its checksum.

zcat: command not found (macOS)

Use gzcat instead of zcat, or `gunzip -c reads.fastq.gz | wc -l`.