7

次の課題があります。

歌の歌詞は 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.

\2最後に の意味がわかりません。

4

1 に答える 1

15

後方参照です。

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.
于 2012-04-14T09:29:02.237 に答える