There are mainly two types of regular expressions in Linux:
- Basic regular expressions that are used by vi, sed, grep, and so on
- Extended regular expressions that are used by awk, nawk, gawk, and egrep
Here, we will refer to extended regular expressions as regular expressions in the context of AWK.
In AWK, regular expressions are enclosed in forward slashes, '/', (forming the AWK pattern) and match every input record whose text belongs to that set.
The simplest regular expression is a string of letters, numbers, or both that matches itself. For example, here we use the ly regular expression string to print all lines that contain the ly pattern in them. We just need to enclose the regular expression in forward ...