Solved

AWK ending script early

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 136
Expand macro to ask for filename column 8 37
bigDiff challenge 17 106
Message not shown 5 50
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

772 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