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

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts