Sometimes we get shocked when something unexpected occurs. We get stuck and feels like everything is over. Today I also had such a situation.
I was writing an important document over the last couple of days. I hadn’t kept a backup or draft, I had only single Open office text document file. While I was writing, my laptop got switch off suddenly due to some power button issue. When I powered it on and looked at the file, I got stuck. It shows 0 byte as size. I ran file filename.odt, it shows empty data. OMG. It was around 12 Pages of text and WTH !
I lost my hope. But I decided to go for an experiment. Installed TestDisk, which the GNU/Linux recovery suite. Ran the Photorec command. I selected the disk drive where the data is located, then chose scan unallocated space. I received 1000s of files of different format.
I returned me a list of 200 files. I thought of greping the files to find the right file. But I understood that grep over binary files won’t work. So I moved odt files to a directory.
Then I manually opened some of the files. Then I got earlier versions of the file which contains initial text only. So my breath became normal. I looked at the file size and noticed that it is of the size 27KB. So again I filtered out files using size as a contraint.
So I got a list of fewer number of files. I manually found out highest size which in the order of 27K, which was the file with all text I wrote. Voila, thanks to find and testdisk. :)