On Wed, Sep 10, 2014 at 01:32:18PM -0400, Steve Simmons wrote: > is a helluva lot more sensible than > > cd $LOG > # take actions here... > rm *
Oh dear gods. That's madness. Never EVER do that. If the cd command fails for any reason, you will remove all the files in the wrong directory. cd "$LOG" && rm -- * # This is much, much safer. Or if there are several actions that all need to be done in the $LOG directory, wrap it in something you can escape from, like a function: cleanup() { cd "$LOG" || return # other actions rm -- * }