help with READ command

Dear forum, i am trying to write a little programme which should greet the user, tell him/her the current path and visualize the directories (NO FILES, JUST DIRECTORIES). what follows is chosen interactively by the user. what i've tried so far is:

echo "Hi $LOGNAME"
echo "You are in $PWD. Do you want to visualize the DIRECTORIES in $PWD? {YES/NO} \c"
read answer
case "$answer" in
yes|YES|Y|y)
ls

-----ANY OTHER METHOD HERE TO LIST JUST THE FEW DIRECTORIES I HAVE IN MY $pwd, SO WITH NO HIDDEN FILES...JUST directories?----

echo "Now type the DIRECTORY you want to work with: \c"
read choice

-----HERE I WOULD LIKE TO TYPE THE NAME OF A DIRECTORY, MOVE TO THAT DIRECTORY (i have tried WITH CD COMMAND but does not work) AND WOULD LIKE MY PROMPT TO CHANGE INTO THE NEW DIRECTORY I'M IN.......BUT HOW??????------

;;
no|NO|N|n)
echo "If not, please create a new DIRECTORY: \c"
read newdirectory
mkdir $newdirectory

----i still want to remain in my programme.....HOW? TO CHANGE NOW TO THE NEW CREATED DIRECTORY....-----

;;
esac

FINAL QUESTION:

IS THERE A WAY TO TEST THAT I AM WORKING only WITH DIRECTORIES LIKE:

IF TEST -D ETC.
THEN
ECHO "THIS IS A DIRECTORY"
ELSE
ECHO "SORRY, YOU MUST SPECIFY A DIRECTORY \C"
or "THE DIRECTORY IS EMPTY"

i would like to test:

1)that the directory exists,
2)that it is not empty,

THANK YOU!

sorry...i am new to the unix world!

:slight_smile:

To list only directories, maybe one of these:
find . -type d -print
find . -type d -print | xargs ls -d

To read a directory name and cd there, you already have "read choice", so-
cd $choice

And continue to use $PWD in your prompts if you want that.

if [ -d "$choice ] ; then
echo $choice is a directory
fi
will test if $choice is a directory and this also implies that $choice must exist.

And be careful of that caps key. Case is important. if != IF

thank you very much