in reply to Why do I sometimes get null characters after the line feed when writing to files?

The output doesn't contain a null character; its just an artifact of the way od displays contents in units of 2 bytes:
$ echo "ab" > /tmp/foo $ ls -l /tmp/foo -rw-r--r-- 1 davem davem 3 Dec 18 16:16 /tmp/foo $ od -xc /tmp/foo 0000000 6261 000a a b \n \0 0000003 $ echo "abc" > /tmp/foo $ ls -l /tmp/foo -rw-r--r-- 1 davem davem 4 Dec 18 16:17 /tmp/foo $ od -xc /tmp/foo 0000000 6261 0a63 a b c \n 0000004 $
(Note that the first one is length three, but od displays a fourth null byte.)

Dave.

  • Comment on Re: Why do I sometimes get null characters after the line feed when writing to files?
  • Download Code