I made the following menu per the instructors requirements. He stated for extra credit have it loop until somone chooses a number on the menu to exit. he said use a "do while" ? I'm only halfway through my unix class and am new to scripting. can someone explain looping? or how i can do this in this script.? Thanks!
#! /bin/ksh
#Andrew Dubas - November 27, 2002
#simple menu script
clear
echo " 1. executes ls -la \n 2. show current directory \n 3. home directory \n 4. display a file you enter \n 5. Exit "
echo
echo "please enter a choice: \c"
read n1
if test $n1 = 1
then
ls -la
elif test $n1 = 2
then
pwd
elif test $n1 = 3
then
clear
echo "you are now in your home directory"
cd
elif test $n1 = 4
then
echo "please enter a file \c"
read filex
if test -f $filex
then
cat $filex
elif test -d $filex
then echo "$filex is a directory not a file please try again"
fi
elif test $n1 = 5
then
clear
echo "good bye"
else
echo "you must enter a number between 1-5"
fi
just have to get it to loop now, im not sure how a loop will effect the current structure, but with some guidence I can give it a try and debug it.
Andrew
#! /bin/ksh
#Andrew Dubas - November 27, 2002
#simple menu script
clear
echo " 1. executes ls -la \n 2. show current directory \n 3. home directory \n 4. display a file you enter \n 5. Exit "
echo
echo "please enter a choice: \c"
read n1
if test $n1 = 1
then
ls -la
elif test $n1 = 2
then
pwd
elif test $n1 = 3
then
clear
echo "you are now in your home directory"
cd
elif test $n1 = 4
then
echo "please enter a file \c"
read filex
if test -f $filex
then
cat $filex
elif test -d $filex
then echo "$filex is a directory not a file please try again"
fi
elif test $n1 = 5
then
clear
echo "good bye"
else
echo "you must enter a number between 1-5"
fi
just have to get it to loop now, im not sure how a loop will effect the current structure, but with some guidence I can give it a try and debug it.
Andrew