0

What command would you give to list all English-language words that are exactly 5 characters long and that begin with an upper or lower-case vowel (‘a’, ‘e’, ‘i’, ‘o’, ‘u’, or ‘y’), have a lower-case ‘t’ in the middle position, and end with a lower-case ‘s’?

The remaining letters could be any character that occurs in English words, including but not limited to upper and lower-case alphabetics, numbers, hyphens, etc.

2 Answers2

1

You had it almost!

grep ^[AaEeIiOoUuYy].t.s$ /usr/share/dict/words 
tink
  • 14,342
  • 4
  • 46
  • 50
0

Since I prefer complex pipelines to complex regular expressions, here's my take:

cat /usr/share/dict/words \
    | grep -E -x ".{5}" \
    | grep '^[aeiouyAEIOUY]' \
    | grep '..t.s'

(Useless use of cat added for readability).

On my Ubuntu it produces this output:

Art's
Estes
Oates
Oct's
Yates
act's
altos
ant's
antes
antis
art's
autos
iotas
oat's
oaths
out's

(You can replace .{5} with \w{5} or with [a-zA-Z0-9-]{5} or whatever you like).

I've actually written a similar script to chea.. I mean, help me with crosswords.

root
  • 5,528
  • 1
  • 7
  • 15