Case Statement in Shell
Level 3110 keystrokes
case statement matches a value against multiple patterns.
Shell code
# Compares the first script argument with each pattern in order1case "$1" in # start) matches the word start; ;; ends the branch # The output shown assumes the script was run with start2 start) echo "Starting..." ;;3 stop) echo "Stopping..." ;; # * matches anything else, so it is the default; $0 is the script name4 *) echo "Usage: $0 {start|stop}" ;;# esac (case spelled backwards) closes the statement5esacOutput
Starting...
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Shell code and how often they appear.
"× 8;× 6.× 6)× 3$× 2:× 1{× 1}× 1*× 1|× 1