LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-13-2012, 09:54 AM   #1
jbeiter
Member
 
Registered: Jul 2004
Posts: 105

Rep: Reputation: 15
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

Last edited by jbeiter; 02-13-2012 at 10:01 AM.
 
Old 02-13-2012, 09:59 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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).
 
1 members found this post helpful.
Old 02-13-2012, 10:08 AM   #3
jbeiter
Member
 
Registered: Jul 2004
Posts: 105

Original Poster
Rep: Reputation: 15
Thanks! that did it
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Nested Statements for Additional Tests in Bash LXer Syndicated Linux News 0 04-17-2011 08:10 PM
need answers regarding case statements in bash scripts jahobjafwar Linux - Newbie 4 09-04-2010 09:46 PM
bash scripting problem with nested if statements in while loop error xskycamefalling Programming 4 05-11-2009 03:14 PM
Case statements and vars for bash script geech Programming 1 01-09-2009 04:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration