Так что обычно я довольно хорошо разбираюсь в использовании grep с регулярными выражениями, но я одержим этой простой вещью. У меня есть следующий текстовый файл с именем first-para.txt (показан ниже), и я хочу найти все строки, начинающиеся ровно с трех строчных символов «^ [az] {3}», но не могу выполнить шов, чтобы он работал.
It was the best of times,
it was the worst of times,
it was the age of wisdom,
it was the age of foolishness,
it was the epoch of belief,
it was the epoch of incredulity,
it was the season of Light,
it was the season of Darkness,
it was the spring of hope,
it was the winter of despair,
we had everything before us,
we had nothing before us,
we were all going direct to Heaven,
we were all going direct the other way--
in short, the period was so far like the present period, that some of
its noisiest authorities insisted on its being received, for good or for
evil, in the superlative degree of comparison only.
И попытка этого дает мне все строки, начинающиеся с трех или более строчных букв, но я не понимаю, почему я получаю не только одну строку, которая на самом деле начинается с трех символов, ее .... '
$ grep '^[a-z]\{3\}' first-paragraph.txt
its noisiest authorities insisted on its being received, for good or for
evil, in the superlative degree of comparison only.
$ grep '^[a-z]\{3\}$' first-paragraph.txt # no lines
$ grep '^([a-z])\{3\}' first-paragraph.txt # no lines