PDA

View Full Version : Hmm, is wc supposed to behave that way?


fonz
February 24th, 2009, 17:48
When wc is instructed to report a line count, it gives one line less than I expect when the last line doesn't end with a newline. Judging from the source, it seems to me like wc simply counts newlines, which would explain why a last line not ending in a newline won't get the line counter incremented.

Is this a bug or is wc supposed to behave like this?

Alphons

crsd
February 24th, 2009, 17:54
-l
Write to the standard output the number of <newline> characters in each input file.

http://www.opengroup.org/onlinepubs/9699919799/utilities/wc.html

fonz
February 24th, 2009, 17:59
All I needed to know, thanks!