Simple case statement

suggest change

In its simplest form supported by all versions of bash, case statement executes the case that matches the pattern. ;; operator breaks after the first match, if any.

#!/bin/bash

var=1
case $var in
1)
  echo "Antartica"
 ;;
2)
  echo "Brazil"
 ;;
3)
  echo "Cat"
 ;;
esac

Outputs:

Antartica

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents