Solved

AWK ending script early

Posted on 2003-12-02
2
272 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
[X]
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
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 174
Prevent this page from creating additional dialogs. 3 719
string initialization in java 11 117
ShiftLeft challenge 21 88
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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

749 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