LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   BASH Question - nested case statements (https://www.linuxquestions.org/questions/linux-software-2/bash-question-nested-case-statements-929116/)

jbeiter 02-13-2012 09:54 AM

BASH Question - nested case statements
 
I'm not much of a scripter so I'm not sure if this simply can't be nested like this or if I have a syntax error. It is bombing at line 106 with "syntax error near unexpected token ')'

line 106 ` PROD-LOC2)'


case "$SYS_TYPE" in
97 PROD)
98 case "$SYS_ENV" in
99 PROD-LOC1)
100 case "$SYS_IP" in
101 172.168.120.*) sed -i -e "s/foo/bar/" /etc/hosts
102 sed -i -e "s/foo/bar/" /etc/hosts
103 ;;
104 esac
105
106 PROD-LOC2)
107 case "$SYS_IP" in
108 172.168.120.*) sed -i -e "s/foo/bar/" /etc/hosts
109 sed -i -e "s/1foo/bar/" /etc/hosts
110 ;;
111 esac
112 esac
113 TEST)
114 case "$SYS_ENV" in
115 TEST-LOC1)
116 case "$SYS_IP" in
117 172.168.120.*) sed -i -e "s/foo/bar/" /etc/hosts
118 sed -i -e "s/foo/bar/" /etc/hosts
119 ;;
120 esac
121 TEST-LOC2)
122 case "$SYS_IP" in
123 172.168.120.*) sed -i -e "s/foo/bar/" /etc/hosts
124 172.268.120.*) sed -i -e "s/foo/bar/" /etc/hosts
125 sed -i -e "s/foo/bar/" /etc/hosts
126 ;;
127 esac
128 ;;
129 esac
130 ;;
131 esac

doesn't like nesting case statements that deep?

Ugh.. the site takes out the formatting. Makes this kind of hard to read

colucix 02-13-2012 09:59 AM

You simply missed a
Code:

;;
at line 105. Please, use CODE tags to make the code more readable and preserve spacing and indentation (if any).

jbeiter 02-13-2012 10:08 AM

Thanks! that did it


All times are GMT -5. The time now is 05:30 PM.