I want to add word boundaries to this awk command:
awk \'{$0=tolower($0)};/wordA/&&/wordB/ { print FILENAME \":\" $0; }\' myfile.txt
\<
and \>
conventions for word boundaries. If you're stuck with a recalcitrant awk, then since awk is normally splitting lines into tokens anyway, it might make sense to use:
function word(s, i) {
for (i=1;i<=NF;i++) {if ($i ~ "^" s "$") {return i}};
return 0;
}
So, for example, instead of writing
/\<[abc]\>/ { print "matched"; }
you could just as easily write:
word("[abc]") { print "matched"; }