Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

AWK ending script early

Posted on 2003-12-02
2
264 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

791 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