Does just 'rm -rf' delete any files?

I recently ran rm -rf, not rm -rf /, but nothing happened. I just get a result like this:

Terminal

I was scared because I am worried that it could've deleted some files, but it didn't. Just be sure, could this have deleted any files from my directory?


Solution 1:

No, rm -rf will not delete any files because you did not supply an argument to the command.

Solution 2:

From the manual page:

rm removes each specified file.

This means you can use it to remove a list of files at once, e.g. with

rm -rf test1.txt test2.txt

Fortunately, all you did was pass an empty list of files, so it deleted nothing. Also, what @SolarMike says: if you don't know what a command does, don't run it. macOS is designed to 'hide' all dangerous (but potentially powerful) Unix operations from the end user.

Solution 3:

For the layman/Linux/Unix newbie:

rm alone doesn't do anything because you haven't told it what to get rid of.

man rm can explain most of this, if you understand it.

-r means recursive, as in "include everything in subfolders"

-f means force, "don't ask me to confirm" mode

rm -rf(DON'T DO THIS)/ would say delete everything under / (the root folder) without checking (on recent macOS versions SIP will prevent you from removing macOS itself by this, but a lot of other stuff will get deleted)

rm [some file name] would just delete that file.

rm -rf /home/myuser/books would delete everything in myuser's books folder, as well as the folder.

Solution 4:

No but if you want to delete Here's an example:

After you launch Terminal (in your /Applications/Utilities folder) type cd ~/Desktop to navigate to the Desktop directory. If you had a file here named MyFile.rtf that you never, ever wanted to see again, you could run this command:

rm MyFile.rtf

When you press Return, the file will go poof! It will be gone, toast, history. You can’t get it back.