2016-03-16 22 views
-1

而不是給貓filename.txt,我給了貓> filename.txt。我的filename.txt中的全部內容被擦除。我可以檢索內容嗎?它會被存儲在哪裏? 如果有人知道,請幫我拿回內容。是否可以檢索數據如果我在unix中給cat> filename.txt?

+0

內容很可能仍然存儲在磁盤上,但您需要恢復工具來讀取物理磁盤以嘗試查找原始內容。 – T0xicCode

+0

檢查http://unix.stackexchange.com/questions/80270/unix-linux-undelete-recover-deleted-files – xvan

+0

根據您的文件系統類型,'grep'和'dd'的組合可能會起作用,但這不是一種可靠的方法。如果您再次輸入類似的錯字,「dd」可能會弄亂整個系統,所以要小心。請查看https://unix.stackexchange.com/questions/2677/recovering-accidentally-deleted-files/2680#2680 – jDo

回答

1

我對你的(數據)損失表示同情。防止這種情況在未來

一種方法是使用「noclobber選項」殼設置:

$ touch veryImportantFile 
$ cat >veryImportantFile 
uh oh 
$ cat veryImportantFile 
uh oh 
$ set -o noclobber 
$ cat >veryImportantFile 
bash: veryImportantFile: cannot overwrite existing file 
$ echo "I really want to overwrite" >| veryImportantFile 
$ cat veryImportantFile 
I really want to overwrite 

注意使用>|重定向的強制覆蓋。

相關問題