Предполагая, что вы хотите выбрать допустимые слова без учета регистра, где допустимое слово может быть:
- однобуквенное слово "a", "i", "o"
- слово из двух или более букв, начинающееся с гласной
- слово из двух или более букв, заканчивающееся гласной
- слово из трех или более букв с гласной в середине
тогда вы можете использовать:
grep -Eiwo -e '[aio]|[aeiouy][a-z]+|[a-z]+[aeiouy]|[a-z]+[aeiouy][a-z]+'
Опции:
-E
расширенные регулярные выражения (используя |
и +
) -i
без учета регистра -w
границы слов совпадений -o
вывод только совпадений -e regexp
- регулярное выражение для сопоставления
регулярное выражение:
- 4 альтернативных термина, разделенных
|
- выбор однобуквенных слов
- выберите слова, начинающиеся с гласной и содержащие одну или несколько букв после начального гласного
- выберите слова, заканчивающиеся гласной и содержащие одну или несколько букв перед завершающей клятвой el
- выберите слова, начинающиеся с одной или нескольких букв, за которыми следует гласная, а затем одна или несколько букв.
Эти шаблоны не являются взаимоисключающими. Например, учитывая входное слово oboe
, все три из многосимвольных шаблонов соответствуют ему - только однобуквенный шаблон терпит неудачу (в конце концов, он имеет четыре буквы). Однако только один из шаблонов должен соответствовать ему; другие не изменяют вывод для этого слова.
Вот некоторый текст (предположительно из "Дракулы"):
"Then he spoke to me mockingly, 'And so you, like the others, would play
your brains against mine. You would help these men to hunt me and
frustrate me in my designs! You know now, and they know in part already,
and will know in full before long, what it is to cross my path. They
should have kept their energies for use closer to home. Whilst they
played wits against me--against me who commanded nations, and intrigued
for them, and fought for them, hundreds of years before they were
born--I was countermining them. And you, their best beloved one, are now
to me, flesh of my flesh; blood of my blood; kin of my kin; my bountiful
wine-press for a while; and shall be later on my companion and my
helper. You shall be avenged in turn; for not one of them but shall
minister to your needs. But as yet you are to be punished for what you
have done. You have aided in thwarting me; now you shall come to my
call. When my brain says "Come!" to you, you shall cross land or sea to
do my bidding; and to that end this!' With that he pulled open his
shirt, and with his long sharp nails opened a vein in his breast. When
the blood began to spurt out, he took my hands in one of his, holding
them tight, and with the other, my neck and pressed my mouth to
the wound, so that I must either suffocate or swallow some of the---- Oh
my God! my God! what have I done? What have I done to deserve such a
fate, I who have tried to walk in meekness and righteousness all my
days. God pity me! Look down on a poor soul in worse than mortal peril;
and in mercy pity those to whom she is dear!" Then she began to rub her
lips as though to cleanse them from pollution.
"Oh, no, not distressed me," she replied, "but I have been more touched
than I can say by your grief. That is a wonderful machine, but it is
cruelly true. It told me, in its very tones, the anguish of your heart.
It was like a soul crying out to Almighty God. No one must hear them
spoken ever again! See, I have tried to be useful. I have copied out the
words on my typewriter, and none other need now hear your heart beat, as
I did."
Это отсортированный, нечувствительный к регистру список слов выбранный из этого текста командой grep
выше, представлен в столбчатом формате:
a again against aided all Almighty already
And anguish are as avenged be beat
been before began beloved best bidding blood
born bountiful brain brains breast but by
call can cleanse closer come commanded companion
copied countermining cross cruelly crying days dear
deserve designs did distressed do done down
either end energies ever fate flesh for
fought from frustrate full God grief hands
have he hear heart help helper her
his holding home hundreds hunt I in
intrigued is it its kept kin know
land later like lips long Look machine
me meekness men mercy mine minister mockingly
more mortal mouth must my nails nations
neck need needs no none not now
of Oh on one open opened or
other others out part path peril pity
play played pollution poor press pressed pulled
punished replied righteousness rub say says sea
See shall sharp she shirt should so
some soul spoke spoken spurt such suffocate
swallow than that the their them Then
these they this those though thwarting tight
to told tones took touched tried true
turn typewriter use useful vein very walk
was were what When while Whilst who
whom will wine With wits wonderful words
worse would wound years yet you your