There is no end-of-file character in Unix or Linux filesystems. The read()
system call returns 0 on end-of-file condition, if the file descriptor in use refers to a regular file. read()
works differently on sockets and pipes. You don't get a special character to mark end of file.
wc
gave you 30 as a character or byte count because the first line has 12 characters counting end-of-line (ASCII line feed, 0x0a numerically), and the second line has 18, also counting the newline (a.k.a. line feed).
You can double-check the character count in this case with ls -l
, and if you've got hexdump
or xxd
you can get a hexadecimal printout showing you the 0x0a valued newlines.
The C standard library function fgetc()
does return -1 on end-of-file, but that's done in the library code, not by Unix (or Linux) or the read()
system call.
od
command shows new linenl
at the end. Why is it so? – user3539 Feb 28 '13 at 02:49