Leaving for loop on condition


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Leaving for loop on condition
# 1  
Old 02-14-2011
Leaving for loop on condition

hi all,
i have a problem...no dream :-)
i want to scan a file i use the loop famous
while read line
do

do < myfile

but this scan must finish when find the another string .
How can i do it?
best regards for all.
Francesco

Moderator's Comments:
Mod Comment Please use descriptive subjects. "script." doesn't tell anyone what this is about.
# 2  
Old 02-14-2011
You did a typo error :

Code:
while read line 
do
 
done < myfile

you can then code whatever you want in the loop, if you want to go out of the loop, use the break command.
# 3  
Old 02-14-2011
my problem is :
i have this report ....

Engine Busy Utilization CPU Busy I/O Busy Idle
------------------------ -------- -------- --------
Engine 0 0.0 % 0.0 % 100.0 %
Engine 1 0.0 % 0.0 % 100.0 %
Engine 2 0.2 % 0.0 % 99.8 %
Engine 3 0.0 % 0.0 % 100.0 %
Engine 4 0.0 % 0.0 % 100.0 %
Engine 5 0.0 % 0.0 % 100.0 %
Engine 6 0.0 % 0.0 % 100.0 %
Engine 7 0.0 % 0.0 % 100.0 %
Engine 8 0.0 % 0.0 % 100.0 %
Engine 9 0.0 % 0.0 % 100.0 %
Engine 10 0.0 % 0.0 % 100.0 %
Engine 11 0.0 % 0.0 % 100.0 %
Engine 12 0.0 % 0.0 % 100.0 %
Engine 13 0.0 % 0.0 % 100.0 %
Engine 14 0.0 % 0.0 % 100.0 %
------------------------ -------- -------- --------
Summary Total 0.2 % 0.0 % 1499.8 %
Average 0.0 % 0.0 % 100.0 %

must begin with "Engine 0" and must finish when match the string "Average"
# 4  
Old 02-14-2011
We already replied to this in the thead you post about your 'grep problem'

Code:
sed '/Engine 0/,/Average/!d;/Average/q' pippo.out

# 5  
Old 02-14-2011
the output don't give nobodoy results.

:-(

Moderator's Comments:
Mod Comment This is the same discussion as your other thread, "grep problem". Please continue there.

Last edited by Scott; 02-14-2011 at 10:09 AM..
# 6  
Old 02-14-2011
Quote:
Originally Posted by FrancescoIt
the output don't give nobodoy results.

:-(
Then go back to your initial thread

grep...? problem

and post an update about the problem you encountered.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check two condition in while loop

Hi, I Have to check two condition in while loop every 2 minutes. while loop is accompanied with number of times it will check.Please help in putting the two condition in while loop as appropriate. z= input value, A=1 while do 1.check the file output,if the file output is N then keep on... (2 Replies)
Discussion started by: netdbaind
2 Replies

2. Shell Programming and Scripting

While Loop with if else condition

Hi, I was trying to write a shell script which reads csv file and sends mail in html format along with tables. Hope i have completed 1st part , but while sending mail i was trying to highlight some rows in the table based on the egrep outcome. If the string exists in line/INPUT, i am trying to... (4 Replies)
Discussion started by: varmas424
4 Replies

3. Shell Programming and Scripting

Case loop condition

hello, I would like to do exit at the end ie list all errors before exiting How to put the token exit in a variable with a loop ? Thanks function g1 () { case "$1" in (-0-0 | -0-1 | -0-2 | -0-3 | -1-0 | -1-1 | -1-2 | -1-3) # nothing, OK ! ;; (*) echo 'Fatal, $1 = '"'$1'"', Date... (9 Replies)
Discussion started by: amazigh42
9 Replies

4. UNIX for Advanced & Expert Users

While loop only if a condition is met

All, I wrote the following section of code (which logically in PHP would of worked): tmpPATH=${1} tmpTAG=${2} if then while read tmpTAG tmpPATH do fi echo $tmpTAG echo $tmpPATH if then done < ./config.cfg fi (4 Replies)
Discussion started by: Cranie
4 Replies

5. Shell Programming and Scripting

Use of -z in while loop condition

Hi, Could you please tell what is the meaning of -z in while loop condition. For example, while ; do echo "*** Enter the age " readage (3 Replies)
Discussion started by: vidyaj
3 Replies

6. Shell Programming and Scripting

if condition in a while loop

Gurus, I need to read a line from a file and strip the characters from it and compare the stripped value with the value I pass to the script while executing it. Below is the code for the same. But when i execute the code, it is throwing an error. #!/bin/ksh . /home/.i_env ... (14 Replies)
Discussion started by: svajhala
14 Replies

7. 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

8. Shell Programming and Scripting

how can i put the condition in for loop for the below.

i have the equation like below 07:35:07 ( AB : 2319f.ab * 22) + ( AB : 2320f.ab * 22.03 ) + ( AB :2321f.ab * 22.07 ) ...... N i want put ":" as a delimiter and break the equation like below 2319f.ab * 22 2320f.ab *22.03 2321f.ab * 22.07 . . N i know the number of... (1 Reply)
Discussion started by: mail2sant
1 Replies

9. UNIX for Dummies Questions & Answers

What condition to be put in the while loop?

i have got a file where the env command is appended 5 times. i have to now look for the username and display it in the form of 1) PWD=/home/lee.ballancore 2) USER=lee.ballancore 3) MAIL=/var/spool/mail/lee.ballancore 4) LOGNAME=lee.ballancore 5) HOME=/home/lee.ballancore 6)... (1 Reply)
Discussion started by: nehaquick
1 Replies
Login or Register to Ask a Question