Saturday, April 27, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 3902  / 2 Years ago, sat, december 25, 2021, 8:17:13

I had a text file hello.txt which contains about 100 lines.I accidentally deleted all the lines by running echo > hello.txt



Now i want to recover all the 100 lines.Is there any way to recover the lines in that file using terminal commands?


More From » command-line

 Answers
7

You can not get back the contents. There is no mercy.



But search for backup files. If you are lucky enough there will be a file named hello.txt~ for hello.txt in the same directory. Those files are usually created by text editors like gedit or emacs when you edit a file.



If you have such backup file you can get the contents back (you may get back only a part also). Use the following in the terminal,



mv hello.txt~ hello.txt


It is better to have even a part than losing it completely.


[#27571] Monday, December 27, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
itchlos

Total Points: 486
Total Questions: 115
Total Answers: 110

Location: Macau
Member since Fri, Apr 28, 2023
1 Year ago
;