problem with nested if stament

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problem with nested if stament
# 1  
Old 10-01-2007
Tools problem with nested if stament

hi everybody:
could anybody tell me what I'm doing wrong. I've tried to nest if staments like this:

if [condition1]; then
   if [condition2];then
        if [condition3];then
   elif [condition4];then

and the last fi (end stament ) appears like missing.
[: 271: missing ] -----> this is the code line
Thanks in advance. Smilie
# 2  
Old 10-01-2007
put whitespace between [ and condition1, also between condition1 and ]. Do this for all conditional statements and check again.
# 3  
Old 10-01-2007
problem with nested if stament

Actually I've done all brackets with spaces but into one those I forget it.Smilie
Thanks. Smilie
# 4  
Old 10-03-2007
shall we call this Shell trap for the unwary?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with nested if...elif..else

Hi, I'm developing a script which will have a lot of options to be checked for and will be setting things / doing further things accordingly. I'm using a LOT of nested if, elif, else throughout my script. In some cases 5 to 6 levels deep. I'm facing some very basic problems. I've torn my... (4 Replies)
Discussion started by: umar.shaikh
4 Replies

2. Shell Programming and Scripting

Nested if else

Hi, i m trying to create script which logic is like below. if ; then x=`cat /tmp/testoutput.log | grep STOP | wc -l` y=`cat /tmp/testoutput.log | grep RUN | wc -l` if ; then echo "process stop" if ; then echo "process running " else echo "file not found" fi ----------------... (2 Replies)
Discussion started by: tapia
2 Replies

3. Shell Programming and Scripting

Perl nested array problem

I have a array reference which has some number of array references inside it.The nested array references also contains the array references. my $Filename = "sample.xml"; my $Parser = new XML::Parser( Style => 'tree' ); my $Tree = $Parser->parsefile( $Filename ); Here the $Tree is the... (6 Replies)
Discussion started by: karthigayan
6 Replies

4. Shell Programming and Scripting

nested for loops

I need help getting over this bump on how nested for loops work in shell. Say i was comparing files in a directory in any other language my for loop would look like so for(int i=0;to then end; i++) for(int y = i+1; to the end; y++) I can't seem to understand how i can translate that... (5 Replies)
Discussion started by: taiL
5 Replies

5. Shell Programming and Scripting

awk/sed Command: To Parse Stament between 2 numbers

Hi, I need an awk command that would parse the below expression Input Format 1 'Stmt1 ............................'2 'Stmt2 ............................'3 'Stmt3 ............................'4 'Stmt4 ............................'5 'Stmt5 ............................'6 'Stmt6... (1 Reply)
Discussion started by: rajan_san
1 Replies

6. Shell Programming and Scripting

nested loop problem

Please see the following script. basic="a b c" advance="d e f" A="basic advance" for g in $A do echo $g done The result would be obviously basic advance I want to ask how can i get the following result using $A in for loop a b c (5 Replies)
Discussion started by: mmunir
5 Replies

7. Shell Programming and Scripting

Extracting Table names from a Select Stament

Hi, I am working on a code to extract the table names out of a select statement. Is there anybody who has worked on something similar? May be you could provide me with the regular expression for the same. Regards. Silas (2 Replies)
Discussion started by: silas.john
2 Replies

8. Shell Programming and Scripting

Complex problem about nested for loops

Hey, I'm writing this bash script that will test print me many copies of the same program but with different combos of 4 variables being between 1 and 100. Here's the code: #! /bin/bash x=0 for ((a=1; a < 101; a++)) do for ((b=1; b < 101; b++)) do for ((c=1; c < 101; c++)) do for... (4 Replies)
Discussion started by: Silverlining
4 Replies

9. Shell Programming and Scripting

Time out in shell script for a stament/line

Folks, In shell script, can I mention a timeout for a command execution, afterwhich I want to exit from that particular line and proceed furthur. I have part of my script as below: ****************************** cd $EXPECT_HOME expect custom_install.exp mv... (5 Replies)
Discussion started by: gvsreddy_539
5 Replies

10. Shell Programming and Scripting

nested loop

I have two do loops. When I break of the inner loop it doesn't go back to the outer loop but exit the program. (5 Replies)
Discussion started by: chinog
5 Replies
Login or Register to Ask a Question