I accidentally deleted a file by running:
rm -rf ./Desktop/myScript.sh
I think it's possible to recover the file, because the
rm command removes temporarily. How can I recover the deleted file on Mac OSX?
MacOS is a Unix OS and
Strictly speaking (as @ire_and_curses points out) a
The MacOS also has a secure remove command (
[ I should hasten to add that even if you over-write a disk multiple times, there are ways to read what was written a dozen or more times before. To properly sanitize a disk for disposal really requires an acid bath, a big hammer and a shredder. ]
Opening a file and immediately
In Unix and Linux (of which the MacOS is a branded Unix), an
Depending on your content, but you can use different 3rd party softwares to do that, e.g.:
and many more.
You can find more apps by typing 'data recovery' in App Store.
More advanced way is to boot your OSX in recovery mode (or umount your partition if you can) and look for it manually (if you remember some specific text from your script).
First, we can confirm that it is possible for you to recover deleted files on Mac after using rm command, even it is not an easy job. Usually, when you delete files or folders in through OS X terminal using the rm -rf, the content of the files or folders are not permanently erased. The system only removes the link to the file making it unable to be found or accessed without special tools. And space these files occupy is marked as free space and can be used for new files or for additional content added to existing files. So, you can easily get back the deleted files on Mac with ease if you using a reliable Mac data recovery software. But here one thing you should note is that you’d better stop using the disk in order to prevent your deleted files from being overwritten.
Many tutorials can be applied here like this iPhone whatsapp recovery.