I accidentally executed man ls > info.txt
and now I don't know how to recover the contents of the file.

- 56,709
- 26
- 150
- 232

- 151
-
Unless you have a backup somewhere, you're SOL. Sorry. – Shadur-don't-feed-the-AI Oct 28 '17 at 11:39
-
See also: https://unix.stackexchange.com/q/80270/117549 – Jeff Schaller Oct 28 '17 at 11:44
-
@JeffSchaller those links are about delete/undelete entire files, not about content of them. – Fatemeh Abdollahei Oct 28 '17 at 11:48
-
But is it still in RAM or swap? If yes, it won’t be for long. Search for a combination of words present in your old file. – user2497 Oct 28 '17 at 13:17
2 Answers
you've wrote the output of "man ls
" command in a file that you called it "info.txt
".
If your info.txt file was empty, now easily you can delete your file and create new one by using these commands:
#rm -f info.txt
#vi info.txt
(thenCtrl + X and press yes to save it.)
Or:
you can open info.txt
file, and delete content of it.
for example, if you use "nano
" editor, you can follow steps:
# nano info.txt
#ctrl+k
(pressing ctrl+k on each line)
#ctrl+x
save your edition.
But if your info.txt
file had something before overwriting, unfortunately you can't retrieve it.

- 66,769
If you're hoping to recover the contents of info.txt, I'm sorry but you're SOL -- that data has been overwritten by the output of the man
command. Not just deleted, which can sometimes be recovered, but overwritten, which generally can't without a professional (IE, law enforcement forensics or higher grade) data recovery setup.

- 31,260