The application I am working has to create files and in the final line of the file it has to include the number of the lines in the file. All simple enough and it did exactly what it was supposed to do.
However when I came to check the results manually I used the unix 'wc' command and this gave me a row count 1 less than what I was expecting and what the footer said was in the file. Strange.
I edited the file with 'vim' and low & behold wc was incorrect - what is going on ?
I then edited the file with hexEdit and noticed there was no CR & LF on the last line. Adding these made wc give the correct count.
3 comments:
I saw the same thing today. Were you able to figure out why? I copied the files with pscp from windows to unix
Must admit, I did not look any furthur. Sorry.
This is a mismatch between Unix and Windows. Windows does not require a final newline. Unix does. In Windows, if there is a final newline, it's treated as a blank line.
Post a Comment