What does "\ 2" mean at the end of a regular expression

I have the following purpose:

The lyrics are in a file named stairway.txt. Which of the following lines will be printed after this command:

grep -E '(^.{4})(.{2}).*[ ]\2' stairway.txt (a) Yes, there are two paths you can go by but in the long run (b) Its just a spring clean for the May queen. (c) Don't be alarmed now. (d) If there a bustle in your hedgerow. (e) Theres still time to change the road you're on. 

I don’t understand what \2 means at the end?

+7
source share
1 answer

This is a backlink.

From http://www.selectorweb.com/grep_tutorial.html :

Backreference is the expression \ n, where n is a number. It matches the contents of the nth set of parentheses in the expression.

In addition, the answer: (d):

 $ grep -E '(^.{4})(.{2}).*[ ]\2' test.txt If there a bustle in your hedgerow. 
+12
source

All Articles