0

I have been searching for the proper Syntax to a switch statement for Unix SunOS. It seems I'm out of luck, perchance anyone can post an example?

Lucas Kauffman
  • 16,880
  • 9
  • 58
  • 93
Mohammad AL-Rawabdeh
  • 1,612
  • 12
  • 33
  • 54

2 Answers2

1

In bash there is the case statement

case string1 in
str1)
   commands;;
str2)
   commands;;
*)
   commands;;
esac
user9517
  • 115,471
  • 20
  • 215
  • 297
0

The switch statement in bash is called case. See help case for details.

case "$1" in
  -p) echo 'Hello, world!' ; exit 0 ;;
  -h|*) usage ; exit 1 ;;
esace
Ignacio Vazquez-Abrams
  • 45,939
  • 6
  • 79
  • 84