grep: Back-references and Subexpressions

 
 3.5 Back-references and Subexpressions
 ======================================
 
 The back-reference ‘\N’, where N is a single digit, matches the
 substring previously matched by the Nth parenthesized subexpression of
 the regular expression.  For example, ‘(a)\1’ matches ‘aa’.  When used
 with alternation, if the group does not participate in the match then
 the back-reference makes the whole match fail.  For example, ‘a(.)|b\1’
 will not match ‘ba’.  When multiple regular expressions are given with
 ‘-e’ or from a file (‘-f FILE’), back-references are local to each
 expression.