Sometimes it’s nice to quickly check how many sequences are in a FASTA format sequence file.
It barely warrants it’s own blog post, but here we go anyhow: my one-liner shell script for counting the number of sequences in a FASTA “flat-file database”, based on the presence of the “>” header symbol.
# ~/bin/countseqs
# Counts the number of sequences in a FASTA format file
grep ">" $1 | wc -l
Dead easy huh ? I put this in ~/bin/countseqs, make it executable (chmod +x ~/bin/countseqs) and use it in lots of situations, as a quick sanity check.
(oh, btw, this is not public domain and u can’t use it for commercial gain without paying me a license fee. academic users can fax me something for a free license. k thx bye).
Couldn’t help myself … everyone else is doing it

How about
grep -c “>” $1
Yeh, good point. “grep -c” is even POSIX compliant, so I guess that would work with various versions of grep. This page makes fun of my way, and even shows why your way is usually practically superior.
Back when I wrote it, I think I did it with the pipe because I was in the habit of piping various outputs into “wc” to count the lines, so it seemed a a bit more general than using a grep specific feature.
If I am not wrong this is in the Nodalpoint wiki.
Doh ! Prior art !
You are right, it’s here. (It’s quite possible this is where I first saw it, but I’d always thought that I ‘invented’ it independently).