This topic is about AWK – Regular Expression Operators.
This example explains the two forms of regular expressions operators.
Match
It is represented as ~. It looks for a field that contains the match string. For instance, the following example prints the lines that contain the pattern 9.
Example
[jerry]$ awk '$0 ~ 9' marks.txt
On executing this code, you get the following result −
Output
2) Rahul Maths 90 5) Hari History 89
Not Match
It is represented as !~. It looks for a field that does not contain the match string. For instance, the following example prints the lines that do not contain the pattern 9.
Example
[jerry]$ awk '$0 !~ 9' marks.txt
On executing this code, you get the following result −
Output
1) Amit Physics 80 3) Shyam Biology 87 4) Kedar English 85
In this topic we learned about AWK – Regular Expression Operators. To know more, Click Here.
Pingback: AWK - Array Membership Operator - Adglob Infosystem Pvt Ltd
Pingback: AWK - Operators - Adglob Infosystem Pvt Ltd