linux - how to make switch execute 2 cases -
how make switch execute 2 cases?
i tried following code, execute first case
#!/bin/sh action="titi" case "$action" in toto|titi) echo "1_$action" ;; tata|titi) echo "2_$action" ;; esac
the case
statement in bash executes commands in command-list
first match only.
however, in bash version 4
or later introduced ;&
terminator. ;;&
operator ;;
, except case statement doesn't terminate after executing associated list - bash continues testing next pattern though previous pattern didn't match. using these terminators, case statement can configured test against patterns, or share code between blocks, example.
reference: excerpt taken http://wiki.bash-hackers.org/syntax/ccmd/case
so if have bash v 4 or later
give desired result:
#!/bin/sh action="titi" case "$action" in toto|titi) echo "1_$action" ;;& tata|titi) echo "2_$action" ;; esac
Comments
Post a Comment