Learning AWK Programming
上QQ阅读APP看书,第一时间看更新

Quoted metacharacter

A regular expression consisting of a literal or character (letter or digit) is a basic regular expression that matches itself. Sometimes, if we need to use the literal meaning of a metacharacter in a regular expression, we precede it with a backslash. If a character is preceded by a single backslash, \, we say the character is quoted. Quoting suppresses the special meaning of a character when matching. For example, if we want to match the dollar sign, $, in a string, we need to quote it as follows:

$ echo -e "500$\n500INR" | awk '/\$/{ print }'

The output on execution of the preceding code is as follows:

500$