grep: Back-references and Subexpressions

 
 3.5 Back-references and Subexpressions
 ======================================
 
 The back-reference ‘\N’, where N is a single nonzero digit, matches the
 substring previously matched by the Nth parenthesized subexpression of
 the regular expression.  For example, ‘(a)\1’ matches ‘aa’.  If the
 parenthesized subexpression does not participate in the match, the
 back-reference makes the whole match fail; for example, ‘(a)*\1’ fails
 to match ‘a’.  If the parenthesized subexpression matches more than one
 substring, the back-reference refers to the last matched substring; for
 example, ‘^(ab*)*\1$’ matches ‘ababbabb’ but not ‘ababbab’.  When
 multiple regular expressions are given with ‘-e’ or from a file (‘-f
 FILE’), back-references are local to each expression.
 
    ⇒Known Bugs, for some known problems with back-references.