I am trying to use GAWK from CYGWIN to process a csv file. Pass 1 finds the maximum value, and pass 2 prints records corresponding to the maximum value. I am using the .awk file as input. When I use text in a manual, it matches both passages. I can use the IF form as a workaround, but it forces me to use IF inside every pattern match, which is kind of a pain. Any idea what I'm doing wrong?
Here is my .awk file:
pass == 1
{
print "pass1 is", pass;
}
pass == 2
{
if(pass == 2)
print "pass2 is", pass;
}
Here is my output (the input file is just “hi”):
hello
pass1 is 1
pass1 is 2
hello
pass2 is 2
Here is my command line:
gawk -F , -f test.awk pass=1 x.txt pass=2 x.txt
I would appreciate any help.
source
share