Восстановить текстовый файл, который я удалил командой "cat"

786
Deus Deceit

я использовал

cat > filename

не думая об этом, нажмите Ctrl + C, и, естественно, файл теперь пуст ... Есть ли способ восстановить содержимое этого файла?

0

2 ответа на вопрос

0
Gombai Sándor

In theory: yes.

IF you are really lucky and new data was not written onto the very physical blocks your original file had been stored upon, AND you know string patterns that had been contained in the file, AND you have a live/rescue media to boot from or another machine that you can attach the disk to,

THEN you can create an image of your partition or open the /dev/xxxx file directly with some binary(-safe) editor like vim or some viewer like mcview and look for the string patterns in the images/disk.

Probably, the condition tells you something about the odds and the "look for" process makes you guess how time consuming this is. I've been there before.

0
fanton

Do you happen to have another process that has that file open? If yes, maybe they have it mapped into their memory and you could recover the contents from there. Otherwise, you can find additional answers here.

To find out if some process does have it open, you can try looking into your procfs, like this:ls -l /proc/*/fd/* | grep $FILENAME. Or you could use fuser. Good luck!

Похожие вопросы