Regular expressions

A regular expression is a pattern enclosed in forward slashes. A regular expression can contain meta-characters. If the pattern matches any string in the record, then the condition is true and any associated action, if mentioned, will be executed. If no action is specified, then the record is simply printed on the screen.

Meta-characters used in awk regular expressions are as follows:


What it does


A single character is matched


Zero or more characters are matched


The beginning of the string is matched


The end of the string is matched


One or more of the characters are matched


Zero or one of the characters are matched


Any one character in the ...

Get Learning Linux Shell Scripting - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.