Solved

AWK ending script early

Posted on 2003-12-02
2
234 Views
Last Modified: 2013-12-26
I am trying to write an awk script that gets values from a sequential file.  I am using an if statement to check which lines to get.  The if statement will start off being false, become true for a short period and then become false for the rest of the file.  In order to save time when running the script, I would like the AWK statement to end once the if statement is no longer true.  Can this be done?  How do you end an AWK script early?  Please provide an example.

Thanks in advance

gkatz
0
Comment
Question by:gkatz
2 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 50 total points
ID: 9857717
Hi gkatz,

you can use something like

flag = 0;

if ( condition_true )
{
       flag = 1;
       rest of processing;
}
else if ( flag = 1 )
          exit;

the flag will be initially 0 ...the first time condition is true, it gets set to 1 and the first time that condition is false after that, it exits

Cheers!
Sunny:o)
0
 
LVL 3

Author Comment

by:gkatz
ID: 9858261
Thanks for the quick response Sunny.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now