1

I'm having the following problem:

Some text files (also some binary files) on my system are listed with the correct file size but when I open them, they appear empty.

>ls -la
-rw-rw-r--  1 user user   652 Mar 12 16:17 summary.txt
>cat summary.txt
>

If I display them in midnight commander I get a list of dots (......) and in vi a list of ^@. I'm not sure when it happened, but I guess since the last reboot.

System:

  • Linux ubuntu 3.8.0-37-generic #53~precise1-Ubuntu SMP Wed Feb 19 21:37:54 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
  • ext4

Is there a way to fix it?

Edit: I guess it most be somehow correlated with a system reboot. Can I somehow find out by looking at the log files what happened?

Thanks.

10
  • 1
    Could perhaps be a partially transferred/downloaded file? I know that at least several BitTorrent-clients creates files of the size it need for the file it's downloading, and then fill it with NUL - and if the download fails, NUL will be all the file contain. Don't think it's much you can do; you may have reserved space for the file, but you obviously haven't actually downloaded/transferred it. Commented Apr 8, 2014 at 10:54
  • Did you neglect to mention that your system crashed/lost power shortly after you wrote that file? Commented Apr 8, 2014 at 14:22
  • 1
    The file is corrupted. If the system crashed before you saved the file or just as the file was being written, this is to be expected. Otherwise do a memory test (reboot and choose “memory test” at the Grub prompt, let it run for at least one full pass). Commented Apr 8, 2014 at 22:59
  • @BaardKopperud - thanks for the hint, but the file was there the left time I logged into the system, now it's corrupted. I don't know exactly when the problem occurred. Commented Apr 9, 2014 at 14:36
  • @psusi - it's a virtual machine on our institutes server infrastructure. I saw that it was rebooted but I don't know if it crashed - definitely right after it was written. Commented Apr 9, 2014 at 14:37

1 Answer 1

3

^@ is a representation of the null byte. You can get a better picture from xxd or od.

If the contents of the file has been lost, the fix would be to restore it from the version control system or backups.

3
  • Thanks for your help. I just executed xxd and it seems that only null bytes are in the file: 0000000: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................ ----- Do you have any idea why that happened - or could I somehow find it out. It would be great if it was only a "one time" thing. Commented Apr 8, 2014 at 10:57
  • These things can happen e.g. if two processes write to the same file. Commented Apr 8, 2014 at 11:22
  • or if the file has been scrubbed with dd from /dev/zero Commented Jul 24, 2015 at 3:03

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.