Recover a text file in linux

1.4k views Asked by At

My project c source code file is corrupted while making the tgz of the file. I wanted to make *.tgz of 4 files. The file names are common.c common.h myfile.c and myfile.h. I mistyped the tar command. I used the following tar command by mistake

tar -cvf common.* myfile.* project.tgz

This has corrupted the common.c file. Is there any way to overcome this error?

1

There are 1 answers

0
Lajos Veres On

If the file is really important, than umount the related block device, and you can look into it with the strings command. If the file contains something relatively unique, you can grep it, and if you have a little chance you can save the most of the file. This can work with mounted block devices, but the chance of loosing the data is higher. But it works only under system's where you can access the block device directly.