I'm running Windows 7 and have GnuWin32. I have a several-gigabyte text file with LF (\n
) line endings. I want to know how many lines it has (or alternatively how many LFs it has, which is, let's say, one fewer, but I don't care). What's the fastest or least expensive way to get my answer?
Some possibilities (though I'm sure I'm missing some):
wc -l foo
grep -c $ foo
(with-c
, prints only the count of matching lines)grep -c ^^ foo
(the first caret escapes the second)sed -n $= foo
(-n
prevents printing the line;$
restricts to the last line;=
prints the line number)
(Those are the GnuWin32 utilities. I don't know of any native-to-Windows way.)