I have a text file called junk.txt:hellofoo0-101020fooCindy00000Lou2 0000Who00000wat?0000 00000000000 00000filler00000000000000byeWhen I run the following I get this:cat junk.txt | awk '{if (/foo/ ~ $1) print $1,<-- found match; else print $1}'awk: cmd. line:1: warning: regular expression on left of `~' or `!~' operatorhellofoo0 <-- found match-10 <-- found match10 <-- found match20 <-- found matchfoo <-- found matchCindy00000 <-- found matchLou20 <-- found matchWho00000wat?0000000000 <-- found matchfiller <-- found match00 <-- found match0 <-- found match00 <-- found match000 <-- found match0000 <-- found match0 <-- found match <-- found match0 <-- found matchbyeI understand what is happening when the regex is to the left of the ~.I understand that a 0 or an empty string (null?) will count as a match.What I do not understand is why sometimes a 0 will match, and sometimes it won't.  It seems like it has something to do with whatever record was processed before it, but I thought awk treated each input record independently so they shouldn't affect one another (at least not without some variable assignments or other manipulation).EDIT: In case it matters I'm using GNU Awk 4.1.3
Inconsistent behavior in awk
awk