I have bash script show directory:\

for D in /home/*; do
    if [ -d "${D}" ]; then #If a directory
        domain=${D##*/} # Domain name
        echo "- "$domain;
    fi
done
echo "Finished";

I have 2 Directory name "default" and "suspended". I do not want to list those 2 directory names. Please help me!

1 Answers

2
user1934428 On

Turn on extended globbing:

shopt -s extglob
for D in !(default|suspended)/
do
  domain=...
  ...
done

The !(...)/ selects all directories except those in the list.