Why does the "wc" command say that I have only one line in the file, but in fact there are two?

Take a look at this example:

$ cat < demo
man
car$ 
$ 
$ od -x < demo 
0000000 616d 0a6e 6163 0072
0000007
$ 
$ wc < demo 
1 2 7

As you can see, I have 3 characters ( man: 6d 61 6e), followed by a new line ( \n: 0a), and then three more ( car: 63 61 75), the terminated character NUL (00). It is clear that there are two lines in this file, but the wc command reports that the file has only one. What gives? Or do you think that in order to qualify as a string in Unix, you must be interrupted by a newline? NUL not taken into account?

+4
source share
1 answer

, , Unix, ?

, - POSIX , :

wc , , , , .

+4

Source: https://habr.com/ru/post/1656572/


All Articles