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!