Issue
For example in this awk
tutorial there are three examples:
tolower($1) ~ /mary/ { print "CI Record: " $0; }
$0 !~ /Mary/ { print "Not Mary: " $0; }
$1 == "Mary" { print "Mary Record: " $0; }
Solution
Actually example # 2
is using a regex because of this syntax
/regex/
Which means in your example that if literal text Mary
isn't found anywhere in whole line ($0
) then execute awk code.
Whereas $1 == "Mary"
is doing direct comparison between literal text Mary
and field # 1 ($1
).
Finally tolower($1) ~ /mary/
is again using ignre-case regex match on field # 1 and this means if $1
has text mary
(ignore-case) then execute rest of the awk code.
Answered By - anubhava