Here's a simple oneliner that's mainly intended for maintenance of Windows, (because the problem is typical for Windows, hence the type of quotes), to detect what leftover cruft your PATH environment variable contains from old installations that have since then been removed from your system.

It'll simply list all directories in PATH that do not (any more) exist.

perl -MFile::Spec -le "print for grep !-d, File::Spec->path"

Replies are listed 'Best First'.
Re: Detect cruft in your $PATH
by moritz (Cardinal) on Aug 14, 2007 at 11:03 UTC
    In the bash you have to use single quotes, otherwise the bang ! is interpreted as a reference to the history.

      zsh as well. I'm going to go out on a limb and say tcsh and csh also want single quotes to avoid interacting with the history mechanism . . .