2

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

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
The33Coder
  • 151
  • 6

2 Answers2

1

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.

GAD3R
  • 63,407
  • 31
  • 131
  • 192
Fatemeh Abdollahei
  • 584
  • 1
  • 7
  • 21
1

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.

Shadur
  • 30,641
  • 11
  • 58
  • 69