Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE's and grep



On Tue, Sep 02, 2003 at 12:43:09PM -0500, karina.popkova at verizon.net wrote:
> 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?

If you're searching prose, and you want to match a pattern in a WORD,
and at the same time ensure the same word doesn't contain the
specified vowel, that can get complicated.  Remember that grep matches
patterns contained in a LINE, not per-word.

If your words are one per line, this is much easier.  You can do it
with a simple pipe, like this:

  $ grep <pattern> <file> | grep -v 'a'

Or, if you wanted to make sure ALL of those vowels weren't contained
in the word, 

  $ grep <pattern> <file> | grep -v '[aei]'

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

Again, they'd need to be one word per line, but this would suffice:

  $ grep -v '[a]' file

Just add whatever characters you want to eliminate in the brackets.

> Or do not have the letters a, and e, and i in the same word?

If the file contains more than one word per line (such as a dictionary
with definitions), this won't work.  It can still be done, but you'd
need a lot more logic.  AFAIK, there's no way to do that with a single
regular expression, or even a simple pipeline.

-- 
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.
Replying to it will result in undeliverable mail.
Sorry for the inconvenience.  Thank the spammers.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.blu.org/pipermail/discuss/attachments/20030902/82f8b66c/attachment.sig>



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org