Given that I have the folloiwing chunk of program:
BEGIN {
FS = ":"
print "\n AWKSEARCH - Start:
for (i=2; i < ARGC; i++) {
if (ARGV == "-d"
else if (ARGV == "-f"
else if (ARGV == "-r"
else if (ARGV == "-s"
else if (ARGV == "-x"
exc == "" ? exc = ARGV[i+1] :
exc = exc ":" ARGV[i+1]
++i
}
else if (ARGV == "-i"
inc == "" ? inc = ARGV[i+1] :
inc = inc ":" ARGV[i+1]
++i
}
else if (ARGV == "-t"
txt == "" ? txt = ARGV[i+1] :
txt = txt ":" ARGV[i+1]
++i
}
}
for (i = 2; i < ARGC; i++) delete ARGV
if (disponly == "y"
if (txt == "" && fileonly != "y"
if (exc != ""
$0 = exc
print " $0exc: "$0
for (x = 1; x <= NF; x++) {
exclude[x] = $x
print " exclude"x": "exclude[x]
}
exc = ""
print "x = "x
if (inc != ""
$0 = inc
print " $0inc: "$0
for (d = 1; d <= NF; d++) {
include[d] = $d
print " include"d": "include[d]
}
inc = ""
print "d = "d
if (txt != ""
$0 = txt
print " $0txt: "$0
for (t = 1; t <= NF; t++) {
text[t] = $t
print " text"t": "text[t]
}
txt = ""
print "t = "t
exit
Why is the output of:
> awk -f awksearch dummy -x awk1X1 -t duncan2T1 -x ferret2X3 -i mess4I1 -i pottage5I2 -x soup6x3 -t duck7T2
As follows:
$0exc: awk1X1:ferret2X3:soup6x3
exclude1: awk1X1
exclude2: ferret2X3
exclude3: soup6x3
x = 4
$0inc: mess4I1
include1: awk1X1
include2: ferret2X3
d = 3
$0txt: duncan2T1:duck7T2
text1: duncan2T1
text2: duck 7T2
t = 3
Am I missing something terribly obvious?
dmk