From manual:
-
-f, –force
ignore nonexistent files, never prompt
-
-r, -R, –recursive
remove the contents of directories recursively
Though this options description is different, when trying to delete an empty folder (without rmdir for this example) it gives the same result.
-f
won't print error or anything compared to -r
, is this the only difference or is there a specific type of situations when one option is better than another or situations where one of this option simply won't work while the other will?
Best Answer
This is what the man page in CentOS says:
From what I gather (thanks to some comments below), the following is true for the
-r
and-f
flags:-r
--interactive
flag). Some distributions do this by default./path/to/directory
)-f
example/file1
orexample/*
).yes to all
in WindowsBelow are a few examples, all of them start with the following structure:
I enabled verbosity and interactive mode by default for these examples. Some distros do this while others don't.
rm example
As you can see,
rm
does not remove directories by default.rm example -f
Using the
-f
flag still doesn't allow it to remove directories.rm example -r
As you can see, you are asked for permission for every single file and directory, hidden files are also removed.
rm example/* -f
Here, you are not asked for permission, directories are not deleted and neither are hidden files.
rm example/* -r
Here, the contents of the example directory (not the directory itself) are removed, including hidden files.