Exercise
Matches
What grep would print
replace with
After replacing (use
$1 for group 1; sed writes it \1)Terminal
student@lab:~$
A practice shell, not a full Linux system: grep uses the same PCRE2 engine as GNU grep and prints the same output, plus cat, head, tail, wc, sort, uniq, cut, ls and echo. Type help for the file list and limits.
Explanation
Match information
Same pattern in the shell
These update as you type. grep -P and Perl use the same syntax as this page; plain grep -E (POSIX ERE) is a smaller dialect. grep prints whole lines, or whole matches with -o; it can't print groups on their own.