Take a look at this example please:
$ cat < demo
man
car$
$
$ od -x < demo
0000000 616d 0a6e 6163 0072
0000007
$
$ wc < demo
1 2 7
As you can see, I've got there 3 characters (man
: 6d 61 6e) followed by a newline (\n
: 0a) and then another three (car
: 63 61 75) terminated with a NUL character (00). Clearly, there are two lines in that file, but the wc command reports that the file has got only one. What gives? Or do you think that in order to qualify as a line in Unix you must be terminated with a newline character? NUL doesn't count?
Or do you think that in order to qualify as a line in Unix you must be terminated with a newline character?
Actually, yes - even POSIX
says that:
The wc utility shall read one or more input files and, by default, write the number of newlines, words, and bytes contained in each input file to the standard output.