extended regular expression
The two regular expression dialects of Unix tools: basic (BRE), used by grep and sed by default, and extended (ERE), selected with -E.
In more detail
In basic syntax, repetition counts and grouping need backslashes, as in [0-9]\{2\}; in extended syntax you write [0-9]{2} and (a|b) directly. The matching power is the same, so pick -E for readability.
Examples
grep -E ' [45][0-9]{2} ' access.loggrep ' [45][0-9]\{2\} ' access.logRelated terms
- regular expression — A pattern language for matching text, where characters such as ., *, ^ and $ have special meanings.
- grep — The command that prints the lines of its input that match a pattern.
- sed — The stream editor, which applies editing commands such as find-and-replace to each line of text passing through it.
Taught in
- Finding Lines: grep And Regular Expressions — Bash Scripting & Command Line Automation