Let’s say you want to write a script to return a value or statement based on user input. How would you accomplish this?
Write a scrip to pass a color, return a result based on the color.
My first attempt was through the use of users selection in a particular set of available options. For instance:
#!/bin/bashOPTIONS=”Blue Green Red”select opt in $OPTIONS; doif [ “$opt” = “Blue” ]; thenecho The sky is blue.elif [ “$opt” = “Green” ]; thenecho The grass is green.elif [ “$opt” = “Red” ]; thenecho Roses are red.elseclearecho Not a valid option. Please choose the following above.fi