Q:

Quickest way to get number of lines in a file

I have a very large file. What would be the fastest way to get the line count. Here are some options I considered:
wc -l file.txt

sed -n '$=' file.txt

For a large file (100GB or larger), what would be the fastest way?

A:

Here's an interesting discussion about the different options. Benchmarks copied here:
0.024 sec (avg) - wc -l file.txt
0.121 sec (avg) - sed -n '$=' file.txt
0.396 sec (avg) - nl file.txt | tac |sed -n 1p | awk '{print $1}

Run on a 18 Mb - 500,000 line file.

