Regular Expressions in grep, sed, awk
grep - global regular expression print
^ | Caret | match expression at the start of a line, as in ^A. |
$ | Question | match expression at the end of a line, as in A$. |
\ | Back Slash | turn off the special meaning of the next character, as in \^. |
[ ] | Brackets | match any one of the enclosed characters, as in [aeiou]. Use Hyphen "-" for a range, as in [0-9] . |
[^ ] | match any one character except those enclosed in [ ], as in [^0-9]. | |
. | Period | match a single character of any value, except end of line. |
* | Asterisk | match zero or more of the preceding character or expression. |
\{m,n\} | match m to n occurrences of the preceding. | |
\{m\} | match exactly m occurrences of the preceding. | |
\{m,\} | match m or more occurrences of the preceding. | |
\( \) | Remember this pattern for later usage. | |
\n | The n'th remembered pattern. |
Use backreferences to find lines that contain two of the same lowercase letter in succession.
grep "\([a-z]\)\1" file