1

By mistake, perform the following command:

find ./ type f "*.jpg" -delete

My intention was to delete all the .jpg files, but instead deleted everything that was there. My question is if there is any way to recover those files or in which directory they will be now, because in the recycle bin they are not.

The correct command was:

find ./ type f name "*.jpg" -delete
  • If you want to recover deleted files, you should shutdown and not use the drive until you are ready to do recovery work. It is particularly important to avoid mounting the drive. Instead you should boot the computer from another drive, for example an Ubuntu live drive (DVD, USB pendrive, memory card) made from an Ubuntu iso file. See this link, ubuntuforums.org/…: Advanced repair of a partition table, file system and/or recovery of files – sudodus Jun 20 '17 at 7:31
  • I disagree Zanna. The command will first delete the content of . and then show a lot of errors, 1 of which is 'cannot delete ./'. Sorry VipPunk, but I think your files are gone. I hope you have a backup?? – user680858 Jun 20 '17 at 7:31
  • Btw for future reference - to avoid these specific kinds of problems, first run the find command in a way that you display the filtered files rather than delete right away. Then youll see from the output if your command works as you thought. – Carolus Apr 18 '18 at 6:02
3

Using find ./ type f name "*.jpg" -delete what you did was searching in this paths:

./
type
f
name
"*.jpg"

and then find runs a -delete on everything that was found.

What you can do is use recovery tools like testdisk and photorec. Logically your files are gone, however they just have been unlinked (but their data still occupies disk space). I suggest you to use testdisk utility to recover them - it should work fine for you.

I wrote an answer to recover a single file here. You can also have access to testdisk step by step guide here.

  • @VipPunkJoshersDroopy, I think photorec might help you recover files. – sudodus Jun 20 '17 at 7:47
  • @sudodus there is no point in using a file carver if the files are only unlinked and can selectively be restored easily with a file system-aware tool. – Andrea Lazzarotto Jun 22 '17 at 16:09
  • @AndreaLazzarotto, please tell us which system-aware tool you recommend. – sudodus Jun 22 '17 at 16:12
  • @sudodus not "system", "file system"-aware. Also, Testdisk is already written in the accepted answer so there was no need for me to mention it again. :) Or, if we are talking about NTFS, RecuperaBit (but it's not the case here, it seems). – Andrea Lazzarotto Jun 22 '17 at 18:09

protected by Zanna Dec 21 '18 at 10:46

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.