break out of 'if'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting break out of 'if'
# 1  
Old 05-19-2008
break out of 'if'

is it possible? because i still need to keep on reading even though i don't want to read that particular line
# 2  
Old 05-20-2008
Your question doesn't make sense. If you are inside a while or for loop, continue will skip to the next iteration.
# 3  
Old 05-20-2008
True. "if" doesn't iterate. If you want to break, you can use break, but, that's possible only with in the loop.

Last edited by guruparan18; 05-20-2008 at 01:02 PM.. Reason: Made If as "if"
# 4  
Old 05-20-2008
Question provide example or description of what you are trying to do

As others have said, while in a loop process there is the ability to 'skip' out. However, within an 'if', I know of no way. But, I cannot comprehend a situation where a program would even need to break out of an 'if'.

Thus, more info is required.
# 5  
Old 11-19-2008
break out of 'if'

actually I also trying to do the same thing...

here is the codes sample:

#========================
if ($status == 0) then
#blabla...
if ($status == 0) then
goto SUBB
else
goto SUBA
endif
else
goto SUBA
endif
end

SUBA:
#blabla
exit 0 #break? exit 1?

SUBB:
if (blabla) then
#lalalala...
else
goto SUBA
endif
exit 0 #break? exit 1?
#==================

I want my program to exit the SUBA and SUBB after finish running all the line inside the program..I already try use exit but the program still never stop running.. Smilie
# 6  
Old 11-19-2008
"if" is for either "it happens" or "it doesn't". When you have more than one "elseif" statement in a script, chances are you need to start looking at other ways to write the script, maybe a case statement...
# 7  
Old 11-19-2008
Quote:
Originally Posted by System Shock
"if" is for either "it happens" or "it doesn't". When you have more than one "elseif" statement in a script, chances are you need to start looking at other ways to write the script, maybe a case statement...

its difficult for me to use case statement because I need to check the 1st condition first before proceed to next checking ...different parameter check.


can it be done this way instead?

#========================
if ($status == 0) then
#blabla...
if ($status == 0) then
SUBB
else
SUBA
endif
else
SUBA
endif
end

SUBA()
{
#blabla
}

SUBB()
{
if (blabla) then
#lalalala...
else
SUBA
endif
}
#==================
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Break vs Continue

Okay so I am having trouble understand what the computer will do with a code like this if ; then echo echo "Found the file" blah blah blah for i in `blah blah blah` ; do ... (2 Replies)
Discussion started by: shade917
2 Replies

2. Shell Programming and Scripting

BASH: Break line, read, break again, read again...

...when the lines use both a colon and commas to separate the parts you want read as information. The first version of this script used cut and other non-Bash-builtins, frequently, which made it nice and zippy with little more than average processor load in GNOME Terminal but, predictably, slow... (2 Replies)
Discussion started by: SilversleevesX
2 Replies

3. Shell Programming and Scripting

break: cannot break

hi guys I am working on a menu for linux... some basic stuff. but I have an issue. I got 1 server where something is working and the same thing does not work in the same way in another linux box Basically I am simulating a command line where user insert some commands and to end and go back... (7 Replies)
Discussion started by: karlochacon
7 Replies

4. Shell Programming and Scripting

how to break cat

Greetings. cat $name$telephonenumber >> telephonebook.txtI would like to break cat with the command 'break'. Pretty hard to understand huh? So to clarify it: echo "If you want to stop adding datas to your telephonebook please type 'break' if #this part is probably not good then echo... (2 Replies)
Discussion started by: buddhist
2 Replies

5. Shell Programming and Scripting

Break down a string

I am wondering how can I take a variable that may have multiple items of data and to use each one indenpendently. For example lets say that.... data=/lcl/apps/trm, /lcl/apps/wwe, /prd/sse/qwe, /lcl/ppe/eer Now I would like to be able to process each item found within the data string. As... (5 Replies)
Discussion started by: LRoberts
5 Replies

6. Shell Programming and Scripting

help on page break

Hi, i have a file say samp.s which has 123 a b c d 123 e f g h 123 i j k l 123 m n o p 234 a b c d 234 e f g h 234 i j k l the first 3 characters in each line are considered the key values i have one more file temp.txt which has 123 234 i want to have a page break in... (5 Replies)
Discussion started by: Sheema
5 Replies

7. Shell Programming and Scripting

How to break record

I have this script lines #!/usr/bin/bash my_path=`dirname $0` I_table=$1 echo $I_table in I_table entry going is ccc_con,cc_gui I want to break content of I_table in S_Table and T_table on basis of comma as separtor (2 Replies)
Discussion started by: scorp_rahul23
2 Replies

8. Shell Programming and Scripting

Break command

have a query on this break. I am using a program where I am using a while loop to execute it. It will get into a file take the first file and then ping it and if the ip is reachable then it will mail. Now what happens is that when i ping the ip it does nopt come out of the loop and it says "reply... (11 Replies)
Discussion started by: venkidhadha
11 Replies

9. Solaris

send break

Does anyone know how to send break on a Blade 100? I'm using a serial cable on my laptop and I can see the system boot up just fine, but I want to send break so i can have it boot from cdrom instead of disk. (3 Replies)
Discussion started by: em23
3 Replies

10. Shell Programming and Scripting

TO break a line

hi All, Have a doubt in ksh..Am not familiar with arrays but i have tried out a script.. plzzzzz correct me with the script My i/p File is: (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (Host = 192.168.2.2) (Port = 1525) ) ) (CONNECT_DATA = (SID = TESTDB1) ) ) ... (7 Replies)
Discussion started by: aajan
7 Replies
Login or Register to Ask a Question