RE's and grep

John Jannotti jj at lcs.mit.edu
Tue Sep 2 15:48:39 EDT 2003


<karina.popkova at verizon.net> writes:
> Or do not have the letters a, and e, and i in the same word?

This is the hardest one.  But, assuming one word per line, you can do a
bunch of tests like this:

grep '^[^ae]*i[^ae]*$' /usr/share/dict/words   # words with i but no a or e

That looks for all lines that have i in them, and the i can be surrounded
on either side by any number of characters that are not a or e.

And if you combine the various forms you would need with a bunch of |'s, I
suppose you could do all of your tests in one command, but you might as
well do them separately.

  jj




More information about the Discuss mailing list