Regular Expressions & grep
Regular Expressions
| Pattern | Matches | |
|---|---|---|
. | Any single character | |
* | Zero or more of the previous | |
^ | Start of line | |
$ | End of line | |
[abc] | Any one of a, b, c | |
[^abc] | Any character except a, b, c | |
\{2,4\} | 2 to 4 repetitions (BRE) | |
| `\ | ` | Alternation (BRE) |
grep flags: -i ignore case, -v invert, -r recursive, -n line numbers, -c count, -E extended regex, -o only matching part, -w whole word.
$ grep -E '^[0-9]{3}-[0-9]{4}