AWK is a pattern-matching language. It searches for a pattern in a file and, upon finding the corresponding match, it performs the file's action on the input line. This pattern could consist of fixed strings or a pattern of text. This variable content or pattern is generally searched for with the help of regular expressions. Hence, regular expressions form a very important part of AWK programming language. In this chapter, we will look at regular expressions and how they are handled with AWK.
In this chapter, we will cover the following:
- Regular expressions and their usage in AWK
- The basic regular expression construct
- Understanding the metacharacters of regular expression
- The precedence of regular expressions
- GAWK-specific regular expressions
- Case-sensitive matching
- Escape sequences