Greetings all,
I'm having some trouble writing a menu drive bash script, actually coding the menu part was not difficult however its a problem with a menu option I'm having trouble with.
My menu has 5 options, when the user selects the second option, they are then prompted to enter a number from 1-9 and depending on what number they entered the following output should be displayed
1
12
123
1234
i.e. they entered 4
now this seems like this should really not be that hard, but for the life of me can't figure it out...what I have so far is:::
#!/bin/bash
echo
echo "***********************"
echo "***********************"
echo
declare stop=0
while [ $stop == 0 ]; do
cat <<ENDOFMENU
1 : the first option
2 : the second option
3 : the third option
4 : the fourth option
5 : the fifth option
ENDOFMENU
echo
echo -n " Your choice? : "
read choice
...
case $choice in
2) echo -n " Now please enter a number 1-9 : "
read number
declare i=1
while (( $i <= $number )); do
declare j=1
while (( $j <= $number )); do
echo $j
printf $j + 1
(( j++ ))
done
(( i++))
done
declare stop=1
;;
which outputs:::
1
12
23
34
41
12
23
34
41
12
23
34
41
12
23
34
4
Any help would be much appreciated.