How to use word boundaries in awk without using match() function?

前端 未结 3 1882
太阳男子
太阳男子 2021-01-14 17:42

I want to add word boundaries to this awk command:

awk \'{$0=tolower($0)};/wordA/&&/wordB/ { print FILENAME \":\" $0; }\' myfile.txt
3条回答
  •  没有蜡笔的小新
    2021-01-14 18:21

    This might work for you on Mac OS X:

    awk '{$0=tolower($0)};/[[:<:]]wordA[[:>:]]/&&/[[:<:]]wordB[[:>:]]/ { print FILENAME ":" $0; }' myfile.txt
    

    But as it won't work on linux you're best off installing GNU awk.

提交回复
热议问题