null_reflections
Legendary Coder
Code:
read greeting
case "$greeting" in
"fu*k you" ) echo "fu*k you too!"
;;
[Nn][Yy] ) echo "I think you meant to type yes or no..."
;;
"Hello?" ) echo "Hello there, aren't you sexy!"
;;
"i hate you" | "die, please" | "nerd" | "fu*k off" )
echo "wow! soooo polite!"
;;
* ) echo "try again!"
continue
;;
esac
So above we have a functioning (yet very rude) case/switch script, where a user inputs any one of those responses on the left before the ")", and the shell answers with what matches after "echo". It took me over 20 minutes to make this because of a couple of different things:
Code:
[Nn] [Yy]
Why does bash give an error if there is white space between them?
Code:
"i hate you" || "die, please" || "nerd" || "fu*k off"
Why do these need a pipe instead of an or symbol?
Again, this is just an exercise, i try to make them funny sometimes since no one else would care/understand anyway ;-)