≡ 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}'
Share this tutorial on:
{ 0 comments… add one }
Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">


   Tagged with: , , ,