Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

This may be a *nix thing, I'm not sure.

share|improve this question

2 Answers 2

up vote 15 down vote accepted

An extra byte is for the line end at the end of the file, it's quite common for Linux text editors to add this line end after the last line.

share|improve this answer
    
What a simple explanation. Thanks Alex. –  Kevin Rood Sep 1 '11 at 20:13
1  
The gcc compiler even complains if this blank line is not there. –  Dana the Sane Sep 1 '11 at 20:23
    
@Dana the Sane, yeah and shell interpreters (at least old ones) won't interpret the last line of a shell script if it's not terminated with a line end. –  Alex Sep 1 '11 at 20:31
1  
Some text editors (e.g. vim) will also warn you if you don't have the EOL. –  Andrew Sep 1 '11 at 23:12

Probably a trailing new-line character. For example, a file created in a text editor containing only an 'a' may actually contain 2 bytes:

$ cat /tmp/test_text | hexdump -C
00000000  61 0a                                             |a.|
00000002

However, using echo -n (no new line) gives us a size of 1 byte:

$ echo -n 'a' > /tmp/test_text 
$ ls -l /tmp/test_text 
-rw-r--r--  1 redacted  redacted  1  1 Sep 21:09 /tmp/test_text
$ cat /tmp/test_text | hexdump -C
00000000  61                                                |a|
00000001
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.