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

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


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

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