Originally Posted by catkin
Prudent but not necessary because rm will not remove . and .. (kind of like not cutting off the tree branch you are sitting on). Here's a demonstration at the command line:
c@CW8:/tmp$ mkdir -p dir/dir && cd dir/dir
c@CW8:/tmp/dir/dir$ rm -fr .*
rm: cannot remove directory: `.'
rm: cannot remove directory: `..'
It is to hide these messages that the 2>/dev/null
Thanks, that's good to know. I'd never really tested it, but the thought occurred to me, so I do this to avoid the possibility. This may also be a GNUism, which means the BSDs (and particularly OS X in my case) may not be so thoughtful.
Another interesting feature I recently found out about GNU rm is that by default it will not remove the root directory:
Originally Posted by man rm
do not remove `/' (default)