2

I was trying to rename (mv) few of my files and ran a wrong loop resulting into renaming all the 10 files into one. Now I can see only one file whereas there should have been ten files. How do I recover all the files?

3
  • 3
    You dont. You moved them all in top of one another in turns, deleting them effectively. Feb 16, 2016 at 3:42
  • 1
    unix.stackexchange.com/q/80270/3929 might help you. (What you are now looking for is general undelete/recovery functionality.) Feb 16, 2016 at 4:38
  • 1
    Uh, Linux or cygwin? They're not the same Feb 16, 2016 at 5:14

2 Answers 2

2

Restore the files from backup.

If you don't have a backup, the files were important and you are lucky, you might try extundelete tool. Possibly use another machine to install it and mount the disk as external.

To protect yourself from such mistakes in future: make backups, test before you run, and add following to your bash profile:

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

This will require a confirmation on an attempt to overwrite.

1
  • 1
    If it's really cygwin, it's not going to be an ext3 or ext4 partition, it's likely to be NTFS or FAT. Feb 16, 2016 at 14:57
1

If extundelete doesn't do it for you, the Sleuth Kit has a few tools that might help. fls can give you info about the deleted files in a directory. Testdisk is sometimes helpful, too. Sometimes.

Also, it probably goes without saying, but do not write to the drive after you lose a file! The data is still there but the space becomes marked as unallocated and can potentially be overwritten. Only mount it as read only (at least until you've recovered your files or made a backup image).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .