What the shell case conditional is?

case conditionals like the same multi-branch if statement (refer to the previous article), but it looks more formal than if multi-branch conditional sentence.

conditional case less and is more suitable for a character string of fixed variables.

case syntax how to write it? as follows:

# Variable = variable

# Value = value

case "variable" in

    value 1)

        Command 1

        ;;

    value 2)

        Command 2

        ;;

    *)

        Command 3

        ;;

esac

case "variable" in

    value 1)

        Command 1

        ;;

    value 2)

        Command 2

        ;;

    *)

        Command 3

        ;;

esac









Conditional execution flow case is kind of how it? Above:

blob.png


Guess you like

Origin blog.51cto.com/14573101/2446911