Checking condition inside the loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Checking condition inside the loop
# 1  
Old 03-13-2008
Checking condition inside the loop

Hi all,
I have one clarification i am using the loop which will process for each record .suppose there is f ailure in the first record it need to send mail and process the next .my code:
defcount=`cat <filename>|wc -l`
while [[$cnt -le $defcount ]]
do
if <some condiotion>
then
echo "mail"
fi
done

so if the condition is failed i need to exit the if loop not the entire loop.it should againn go to the starting of loop and process for next record.

Kindly help me out in the issue.

Thanks in advance.
# 2  
Old 03-13-2008
while read line ; do
if condition
fi

done < read_from_file
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If else condition inside for loop of awk command in UNIX shell scripting

Hi , Please excuse me for opening a new thread i am unable to find out the syntax error in my if else condition inside for loop in awk command , my actual aim is to print formatted html td tag when if condition (True) having string as "failed", could anyone please advise what is the right... (2 Replies)
Discussion started by: karthikram
2 Replies

2. Shell Programming and Scripting

Condition checking issue while if

hi, i am using a simple condition end_ct=`sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID << EOF select description from bravo_statistics where trunc(time_stamp)=trunc(sysdate)-1 and description='END CAT'; EOF` echo $end_ct; echo... (30 Replies)
Discussion started by: lovelysethii
30 Replies

3. Shell Programming and Scripting

Condition checking in UNIX

i have a script where i have to find the age of a file, if then echo "dnb file is present for the monthly load" >> $RUNLOG dnb="1" else echo "dnb file has not arrived yet" > $ERRLOG dnb="0" fi i know the file is available so... (3 Replies)
Discussion started by: lovelysethii
3 Replies

4. Shell Programming and Scripting

Check condition inside the loop

Hi, I am in trouble. I can get inside my condition test inside a loop : I am in ksh (solaris) while read file do <commande to retrieve file> >> ${LOG_RETRIEVE_FILE.log} msg_err=$(cat ${LOG_RETRIEVE_FILE.log} | grep "error retrieve") if ; then <sendmail> exit 1 fi done I tried... (6 Replies)
Discussion started by: Aswex
6 Replies

5. Shell Programming and Scripting

Unzip file By checking condition.

Hi.. Gurus I Have a list of .zip files in a directory. I want to check whether each .zip file having some particular file or not (say .jsp) if it's having .Jsp file then create a directory as per the .zip file and extract the content to that directory except the .jsp file, If .zip not having... (3 Replies)
Discussion started by: posix
3 Replies

6. Shell Programming and Scripting

sed solution for condition checking

Hi all , Recently i came across this in FAQ's. I have a file cat rem.txt sreedhar 20 sreedhar 10 sreedhar 15 sreedhar 18 sreedhar 16 sreedhar 30 I have to replace sreedhar with "Sridhar" if the second parameter is > 18. I need to do it in "sed" only. I am wondering how this... (4 Replies)
Discussion started by: panyam
4 Replies

7. Shell Programming and Scripting

Using variables created sequentially in a loop while still inside of the loop [bash]

I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends. As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

8. Shell Programming and Scripting

using flag inside a for loop to check condition

I have a logic like this It initializes the flag variable as "T" at the beginning of the loop everytime Inside each loop it checks for two conditions and updates the flag variable as "A" or "B" In the end of the loop it checks for the value of the variable flag for "A" or "B" and execute... (4 Replies)
Discussion started by: codeman007
4 Replies

9. Shell Programming and Scripting

condition inside a for loop

I have a for loop in my script as shown below. for file_path in $file_list ; do ........my code .......... ...... done Can i restrict the number of files parsing to the variable file_path as 50? That is, even if I have some 100 files in file_list, I need to take only 50 files for... (7 Replies)
Discussion started by: Vijay06
7 Replies

10. Shell Programming and Scripting

Condition checking

Dear all That's another problem from me, i wanna do a lot of if statement checking for correct input by user, will be prompt input again if the input not meet the requirement defined by If or while statement... like this one .... while I know it's less effiency write the program... (14 Replies)
Discussion started by: trynew
14 Replies
Login or Register to Ask a Question