0

I have just copied a file main.tex from /path_1/ to /path_2/:

cp path_1/main.tex /path_2

path_2 already contained main.tex, so it has been overwritten.

Is there a way to recover the original main.tex file located in path_2?

αғsнιη
  • 41,407
DavidC.
  • 101

2 Answers2

4

Standard unix commands do not have any such option.

You will need to restore the file from backup.

In the future, you might want to consider

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

in your .bashrc . This will warn you before overwriting an existing file.

hymie
  • 1,710
0

https://github.com/PabloLec/RecoverPy This tool solved by issue I accidentally saved the file empty... When I reopen file it was empty.

This tool can scan blocks in your drive using a keyword. This tool is specially made to recover overwritten files content not your typical deleted file. But content that is still saved on blocks in your drive.

How to use:

  1. Select the drive you plan to perform the search you need to move the arrow keys then click enter to select the drive
  2. perform a search for keyword you know for certain the file contains
  3. It will bring search results, click on one that contain keyword you looking for
  4. Then you can navigate to nearby blocks and select them to be added to a file
  5. Once you have all the blocks you plan to add to the file click on save file and it save a file in your tmp folder.

This tool is amazing since I manage to recover a file with nearly 4000 lines... It was my notes for some research I have been doing. (Yes I should had made a backup) and I learned my lesson and now the file is online.

John
  • 11
  • I realize that it’s impossible (or, at best, highly impractical) to post a tool in an answer, but can you please [edit] your answer to give some explanation of how this tool works (what are its capabilities and limitations?) and how to use it?  And you see how annoying it is   … (Cont’d) – G-Man Says 'Reinstate Monica' Aug 02 '22 at 16:51
  • (Cont’d) …  to read the exact same comment multiple times?  We feel the same way about identical (or nearly-identical) answers.  Good job on finding three nearly-identical questions.  If you encounter this situation again, please try to figure out which question is the best one (by which I mean 90% which one has the best answer(s) and 9% which one is actually the clearest and most complete question; in case of a tie; pick the oldest one) and flag the others as duplicates.  You will need to earn some reputation before you earn the privilege to flag. – G-Man Says 'Reinstate Monica' Aug 02 '22 at 16:51
  • I edited the answer, if you want to know more you can read the app docs on the github. – John Aug 03 '22 at 01:26