I'm writing up a brief shell script which takes in a number from 1 to 12 and prints out the corresponding month. January = 1 February = 2 etc...
This is what I wrote so far and it's working fine:
#!/bin/sh
x=0
echo Enter the number
read x
case $x in
1)
echo January
;;
2)
echo February
;;
3)
echo March
;;
4)
echo April
;;
5)
echo May
;;
6)
echo June
;;
7)
echo July
;;
8)
echo August
;;
9)
echo September
;;
10)
echo October
;;
11)
echo November
;;
12)
echo December
;;
*)
echo Not sure that about one
;;
esac
However, I was wondering if it's possible to put a case statement into a while loop? so that when someone chooses the number they can choose another one after that again and again. so the program stops only when the user types in "exit", for example.
Is it possible? or is there a better option than using the while loop?
Thank you!