Q:

bash check for subdirectories under directory

This is my first day scripting, I use linux but needed a script that I have been racking my brain until i finally ask for help. I need to check a directory that has directories already present to see if any new directories are added that are not expected.

Ok I think i have got this as simple as possible. The below works but displays all files in the directory as well. I will keep working at it unless someone can tell me how not to list the files too | I tried ls -d but it is doing the echo "nothing new". I feel like an idiot and should have got this sooner. 
#!/bin/bash

workingdirs=`ls ~/ | grep -viE "temp1|temp2|temp3"`

if [ -d "$workingdirs" ]
then
echo "nothing new"

else

echo "The following Direcetories are now present"
echo ""
echo "$workingdirs"

fi

A:

If you want to take some action when a new directory is created, used inotifywait.  If you just want to check to see that the directories that exist are the ones you expect, you could do something like:
trap 'rm -f $TMPDIR/manifest' 0

# Create the expected values.  Really, you should hand edit
# the manifest, but this is just for demonstration.
find "$Workingdir" -maxdepth 1 -type d > $TMPDIR/manifest

while true; do
    sleep 60 # Check every 60 seconds.  Modify period as needed, or
             # (recommended) use inotifywait
    if ! find "$Workingdir" -maxdepth 1 -type d | cmp - $TMPDIR/manifest; then
        : Unexpected directories exist or have been removed
    fi
done

