I have a list of files & directories in a file in some order, and I want to write a script that removes them.
Directories are only supposed to be removed if all of their descendents will also be removed.
(Put another way, they should only be removed if they'd be empty after the script has run many times.)
I'd really prefer to do this in 1 pass.
But doing this in 1 pass seems to require doing things in a correct order (post-order traversal).
I assume this is a known problem... how do people generally solve it in a shell script?