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

by on September 29, 2012 · 0 comments· last updated at September 29, 2012

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

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}'
 


You should follow me on twitter here or grab rss feed to keep track of new changes.

Featured Articles:

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <kbd> <blockquote> <pre> <a href="" title="">

Tagged as: , , ,

Previous Faq:

Next Faq: