我有以下任务:
歌曲的单词位于名为stairway.txt的文件中.在此命令之后将打印以下哪一行:
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's a bustle in your hedgerow.
(e) Theres still time to change the road you're on.
Run Code Online (Sandbox Code Playgroud)
我不明白\2最后的意思是什么?
Del*_*ani 14
这是一个反向引用.
来自http://www.selectorweb.com/grep_tutorial.html:
反向引用是一个表达式\n,其中n是数字.它匹配表达式中第n组括号的内容.
另外,答案是(d):
$ grep -E '(^.{4})(.{2}).*[ ]\2' test.txt
If there's a bustle in your hedgerow.
Run Code Online (Sandbox Code Playgroud)