[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

AWK ending script early

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
gkatz
Asked:
gkatz
1 Solution
 
sunnycoderCommented:
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
 
gkatzAuthor Commented:
Thanks for the quick response Sunny.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now