[wellylug] How do get Switch working in bash (Debian)

Cliff Pratt enkidu at cliffp.com
Wed May 9 09:19:53 NZST 2007


Sigurd Magnusson wrote:
> Why does the following complain with
> ./switchtest: line 5: syntax error near unexpected token `$colour'
> ./switchtest: line 5: `switch ($colour)'
> 
> -------------------------
> #!/bin/bash
> 
> colour=2
> 
> switch ($colour)
> case "red":
> echo "ruddy";
> breaksw
> 
> case "green":
> echo "ecological";
> breaksw
> 
> default:
> echo "odd";
> 
> endsw
> 
Because it is 'case' in bash.

Cheers,

Cliff




More information about the wellylug mailing list