≡ Menu

awk: warning: escape sequence '\<' treated as plain '>'

I‘m trying to match words using GNU awk command and getting the following error:

echo 'foo bar this that blah' | awk '{gsub("\<regex-word\>", "NEW-WORD");print}'

But getting the following warning on screen and it is not working:
awk: warning: escape sequence `\<' treated as plain `<' awk: warning: escape sequence `\>' treated as plain `>'

How do I fix this problem under Unix like operating systems?


You need escape the backslashes too:

{gsub("\\<regex-word\\>", "NEW-WORD");

In this example:

echo 'foo bar this that blah' | awk '{gsub("\\<regex-word\\>", "NEW-WORD");print}'
{ 0 comments… add one }

Leave a Comment


   Tagged with: , , ,