From LQWiki
Recursion is defining a process in terms of itself. This may sound contradictory at first, but is quite possible and can be quite powerful.
Consider traversing and performing an operation on all files in a directory tree. Our recursive process is as follows:
perform operation on directory tree:
- perform operation on files
- are there any directories?
- No: - halt
- Yes: perform "perform operation on directory tree" on each directory.
Note that we do not need to have to know the size or the nature of the directory tree in question - the recursive step where the operation is repeated on each directory handles this for us.
Many utilities in Unix and Unix-like operating systems have a -r flag which stands for recursive, and behaves exactly in this manner.

This page is available under a