anchors

grep -E '^error' log.txt
grep -E 'done$' log.txt

Start and end

^ matches the start of a line $ matches the end of a line Without them, a pattern matches anywhere in the line

Word boundary

\b marks a word boundary in PCRE It is not standard in POSIX ERE Use explicit character classes when portability matters

Multiline

^ and $ match line boundaries by default Some engines offer flags to make them match the whole string Check the engine documentation before assuming

Next

Groups in 05 groups

Posted