0

I have 20 years of work on my USB and I want to clean up .git files. I ran this command in the terminal:

sudo find . | grep .git | xargs rm -rf

When I look in Finder I was shocked: all my projects were gone. Structure under different folders was gone. Everything was deleted. Only two folders were left from more then 30 that were originally there. I check free space and it was 860 GB free. The USB is mounted under /_BACKUP_/DATA/

Can anybody help me to recover files under same structure and filenames?

Scott Weldon
  • 9,673
  • 6
  • 48
  • 67
  • Not an answer to your question, but for future reference... `find . -name .git -type d -exec rm -rf \{\} \;` does what you seem to want, deletes all directories named `.git` found starting in the current directory. – Tonio Dec 02 '16 at 17:52
  • 1
    @Tonio You forgot about `-prune` at the end. – Paul Dec 02 '16 at 18:06
  • 1
    20 years ago there were no USB drives with 1 TB ;-) Data deleted with `rm` are gone, period. Use your backup or you need a tool like [DataRescue](https://www.prosofteng.com/data-rescue-3/). – vadian Dec 02 '16 at 18:07
  • 1
    Welcome to Stack Overflow! This is not a programming question, so it is off-topic for Stack Overflow. You might be able to get help at [Unix.se] or [Apple.se]. Please note that [cross posting is generally frowned upon](//meta.stackexchange.com/tags/cross-posting/info), so you should either (1) post a new question there and delete this one, or (2) flag your question for a [moderator to migrate](//meta.stackexchange.com/q/10249/269535). – Scott Weldon Dec 02 '16 at 18:09
  • 2
    @HelpNeeded Unmount your USB drive immediately and only mount it read-only after that. The longer you have your USB device mounted with write permissions the lower are chances you'll be able to recover your data. – Paul Dec 02 '16 at 18:14
  • Thanks for the help. I will ask moderator to move question. Can this be restored if I undelete only hidden files from mac .Trash file or some of the other system hidden files .DS_store..? Maybe this can help... but what is trange how all folders with files was deleted when I was finding only .git files? – HelpNeeded Dec 02 '16 at 21:08
  • @HelpNeeded As I said before, if you want to restore your files, unmount your USB drive and mount it only read-only from now on. Do not restore any files from `.Trash`, do not touch anything. While it is mounted with write access Spotlight or any other service may write to your device in background and overwrite the sectors you might need. Mount it read-only and recover your files using recovery software to another partition. – Paul Dec 02 '16 at 21:20
  • Thanks very much... I will try that.. how to give Paul a credit for advice..? – HelpNeeded Dec 02 '16 at 21:30

0 Answers0