Answers for "bash check if string equals multiple"

1

bash check if string equals multiple

# Basic syntax:
case your_word in
  words | to | match) <command_to_execute_if_match>;;
  *) <command_to_execute_no_match>;;
esac

# Where
#	- your_word is checked against words, to, and match
#	- If a match is found, the command_to_execute_if_match is run
#	- | is used to indicate "OR"
#	- ;; indicates that no further matches should be considered if a
#		match is found. Use ;& to check additional clauses after
#		executing the code for the current match
#	- * is used to match anything, so it works as the "else" clause here
#	- Additional cases can be added between the first and the last

# Example usage:
case $ANIMAL in
  horse | dog | cat) echo -n "four";;
  man | kangaroo ) echo -n "two";;
  *) echo -n "an unknown number of";;
esac
Posted by: Guest on July-21-2021

Code answers related to "bash check if string equals multiple"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language