I watched an introductory video on using the command line in ubuntu.
It states that in order to erase a directory that is not empty,
you can not use rmdir
, but rm -R
. He called "-R" the recursive modifier.
Now, from python, I know that recursive means "calling itself". But I don't see what is calling itself here.
When I tried to look online for info about the general meaning of -R
, all I found are instructions on how to use it in commands, but no explanations about it itself.
Can someone here explain this to me? not only in the rm
context, but in a general way - what is recursive about -R
and when to use it?
"Recursive" in this context means that the program traverses a directory hierarchy, which is a recursive data structure (a tree), since a directory can contain other directories. As well, the program might use recursion internally to do the traversal. For more details, see Filesystem traversal and other sections on the Wikipedia page "Recursion (computer science)".