RE's and grep

Kevin D. Clark kclark at CetaceanNetworks.com
Tue Sep 2 14:07:34 EDT 2003


<karina.popkova at verizon.net> writes:

> Now, what I really want to do
> is to search for general words
> that have a pattern, but also to 
> exclude a specific vowel or consonant.
> I.E., to make as a part of the search pattern
> that you call an RE, to look for given words
> and make sure that the vowel "a" or the
> vowel "e" is not a part of the word or string?

        grep 'pattern' file.dict | grep -v 'a'

        grep 'pattern' file.dict | egrep -v '(a|e)'

might be what you're looking for.

> How could you find all words in a file that do not
> have the letter: a, or e or i, and so on (???)
> Or do not have the letters a, and e, and i in the same word?

        egrep -v '(a|e|i)' file.dict

might be what you want.

Or do you mean 'a' *and* 'e' *and* 'i'.  If so, I'd write:

        perl -ne 'print if (!/a/ && !/e/ && !/i/)' file.dict


And for a laugh:

        grep cei /usr/dict/words | wc -l
        grep cie /usr/dict/words | wc -l

Regards,

--kevin
-- 
Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
alumni.unh.edu!kdc




More information about the Discuss mailing list