Course Solutions Uncategorized (Solved) : Given Following Shell Script Code Snippet Accepts Name Month Returns Month Change Smaller Q34228663 . . . .

(Solved) : Given Following Shell Script Code Snippet Accepts Name Month Returns Month Change Smaller Q34228663 . . . .

 

Given the following shell script code snippet that accepts thename of a month and returns which month it is, change it so that itdoes this with a smaller code size.

read monthname

case $monthname in

## convert $monthname to number

[Jj][Aa][Nn]*) month=1 ;;

[Ff][Ee][Bb]*) month=2 ;; ## …put the rest of the yearhere

[Dd][Ee][Cc]*) month=12 ;; [1-9]|1[0-2]) month=$monthname ;;

## accept number if entered *) echo “Invalid month: $monthname”>&2 ;;

Expert Answer


An answer will be send to you shortly. . . . .

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post