O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Precedence in regular expressions

In regular expressions, the '|' alternation operator has the lowest precedence, then concatenation, followed by the +, *, and ? repetition operations as well as brackets, '{' and '}'. As in arithmetic expressions, operators of higher precedence are done before lower ones. Also, parentheses can change how operators are grouped. Due to these conventions, parentheses are often omitted, as follows:

$ awk '/Jane|Emily/' emp.dat is same as$ awk '/(Jane)|(Emily)/' emp.dat

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

Jane    Kaur    9837432312  jane@gmail.com      F   hr      1800Emily   Kaur    8826175812  emily@gmail.com     F   Ops     2100

In POSIX, AWK, and GAWK, the '*', '+', and '?' operators stand for themselves when there ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required