Journal eglamkowski's Journal: vi vs. wc 7
The info bar in my vi session says:
foo.csv 40000 lines --100%-- 40000,1 Bot
% wc foo.csv
39999 160742 2521858 foo.csv
Why are these off by one? The last line of the file is NOT a blank line, it has just as much data on it as every other line. This isn't the first time I've noticed it, either. Why can't vi and wc agree on the number of lines in a file?
DOS vs Unix line endings? (Score:1)
Re: (Score:1)
When I drop the csv file into excel, it does show 40,000 lines, and in excel row 1 is number 1, not 0.
Look at it in a hex editor, it appears the last record has no EOL marker of any sort - no new line or carriage return or anything. Between records there is a '0a' byte - new line. No new line after the last record.
So, w
Re: (Score:1)
vi also shows "incomplete last line" when I open a file that doesn't have a trailing EOL character on the last line.
So it looks like they do count things differently.
Off the top of my head... (Score:2)
Last Character (Score:2)
I doubt that that is it, though; wc being the more specialist tool is most likely right, IMO. You could perhaps write your own wc and see if it disagrees? This would seem to me to be the easiest way of adjudicating, short of manually counting the lines...
Definitive answer (Score:2)
Re: (Score:2)