I had a linux plain text document file with close to 100000 lines, a size of 10 Mb. I accidentally overwrote the file via python code. But I got an exception in the middle of the code and think the file socket did not get closed properly. The new file has a few new lines (250) ,BUT the size of the file corresponds to the old one.
I was wondering if the old content will still be there within the file and any chances of recovering the same. I tried using TestDisk and poked around a little bit. But it did not have any option for working on a particular file or maybe I am doing it wrong. I dont have any expertise in file systems and would really appreciate any pointers on how to proceed.


Sounds like the file still in use (opened by other application)

Try these steps

  • Identify PID of the application that is still using the file by lsof <fielname>, let's say 12345 for example
  • Go to /proc/12345/fd directory, hopefully you see a link that links to the file you want
  • Try to copy it to another location
  • No, It is not used by any other application. Thanks anyway! – username1234 Jul 14 '14 at 19:59

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