Recovery after faulty sudo rm -rf functionality in Terminal

I was having issues with OneDrive, where an old folder is unable to be deleted.


I looked online at various options, none of them helped.


One of the last things I tried before giving up and simply living with the problem, was using the following command in terminal from the location jay@Jays-MacBook-Pro ~ % :


sudo rm -rf /Users/jay/Library/CloudStorage/OneDrive-SharedLibraries-Company/Collaborative Projects 2024 - Documents


The 2 parts:

sudo rm -rf (now realizing this is an incredibly destructive deletion function)

/Users/jay/Library/CloudStorage/OneDrive-SharedLibraries-Company/Collaborative Projects 2024 - Documents (this was the folder that wouldn't delete, and still isn't after this command).


I soon found out that the folder I wanted removed, was not removed, but that my Documents under my user folder was completely wiped out instead.


I want to understand why this occurred on my Documents folders and not the folder in the directory path I put in. I don't even know the extent of the damages this has done and am baffled this is possible.


I have tried using several softwares to recover the files, but it doesn't even show up as having ever existed on my system, and it was only 1 day ago!


Can someone please provide any additional assistance that could help me recover these files, I am at a loss for words and deeply upset about this occurrence.


And if not, is there any way to find out what all got deleted so I can do my best to piece it back together again from emails and hopefully past backups.


I do not have Time Machine.

I work on the cloud, but this folder is not linked with my iCloud or OneDrive.

I recently upgraded my OS to the latest one, but am unable to find a recovery point.


Any assistance would be greatly appreciated. If anyone suspects the damages is even larger than I thought, please let me know that as well.


Thanks in advance.

MacBook Pro 16″, macOS 14.3

Posted on Mar 23, 2024 9:18 AM

Reply

Similar questions

3 replies

Mar 24, 2024 2:50 AM in response to Niel

Unfortunately, the whole Documents folder is empty. There was nothing named Projects or 2024 in the Documents folders. So the Documents word was the problem I presume.


Your recommendation would be the following correct?

"/Users/jay/Library/CloudStorage/OneDrive-SharedLibraries-Company/Collaborative Projects 2024 - Documents"

/Users/jay/Library/CloudStorage/OneDrive-SharedLibraries-Company/Collaborative\Projects\2024\-\Documents


Still looking for suggestions about recovery.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Recovery after faulty sudo rm -rf functionality in Terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.