Find all the missing paths in the PATH variable in bash script

Here is a simple script that will list out all the paths in the PATH variable that do not exist.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash -
#===============================================================================
#
#          FILE:  wrong_path.sh
#
#         USAGE:  ./wrong_path.sh
#
#   DESCRIPTION:  Show Directories in the PATH Which does NOT Exist
#
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR:  Amit Agarwal (AKA), amit.agarwal@amit-agarwal.co.in
#       COMPANY:  Individual
#       VERSION:  1.0
#       CREATED:  09/20/2009 09:15:48 AM IST
#      REVISION:  ---
#===============================================================================

set -o nounset                              # Treat unset variables as an error

(IFS=:;for p in $PATH; do test -d $p || echo $p; done)