[ ... ]
doesn’t do pattern matching. /*
is being expanded to the contents of /
, so effectively you have
if [ "$DIR" = /bin /boot /dev /etc /home /lib /media ... /usr /var ]
or something similar. Use [[ ... ]]
instead.
if [[ "$DIR" = /* ]]; then
For POSIX compliance, or if you just don’t have a [[
that does pattern matching, use a case
statement.
case $DIR in
/*) echo "absolute path" ;;
*) echo "something else" ;;
esac