↑↓ move Enter open Esc close

Regular expression

A pattern language for matching text, used by grep, sed and awk.

Regular expressions describe text patterns: ^ anchors the start of a line, $ the end, . matches any character, * repeats the previous element, [0-9] a digit, | alternation. grep, sed and awk are built around them.

They are not globs, despite sharing symbols: in a glob * means "any characters", in a regex it means "zero or more of the previous thing". Mixing the two mental models is a classic source of confusion.

See it in practice

$ grep -E "^(error|warn):" app.log

Anchored to the line start, matching either word. Extended regex (-E) enables the parentheses and pipe without escaping.

Where you'll meet it

Learn these concepts by typing them: the interactive course builds them up lesson by lesson in a real simulated shell.