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

by on September 29, 2012 · 0 comments· LAST UPDATED September 29, 2012

in

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?

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
RequirementsNone
Estimated completion timeN/A

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}'
 
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 0 comments… add one now }

Leave a Comment

Tagged as: , , ,

Previous Faq:

Next Faq: