On 12Oct2006 19:56, Michael Sullivan <[EMAIL PROTECTED]> wrote:
| Can anyone give me an example about how to use grep with regular
| expressions?  I can't figure out how to make it work.  For example, I
| have a directory with maildir style email files in it.  I would like
| to parse the file and return any numeric characters found, for
| example, parts of the IP address.  Here's the email; it's spam, BTW...
[... snip ...]
| Now, I would like to parse this file for numeric data.  Here's my command:
| 
| grep '[:digit:]' 1160675132.P30642Q12M139135.bullet:2,
| 
| Every grep doc I've looked at claims this will work, but none provide
| an example.

So, "man grep" on the specific machine you're using says this will work?
Please cite the OS and release you're using, and the result of:

  which grep

Meanwhile, us old timers have been using [0-9] for decades. This new
fangled [:digit:] stuff is very verbose:-)

| This command is quite happy to return any occurrence of
| the letter d, i, g, or t, but no mention of any numeric data.  I would
| like to use this application (if I can ever find out how) to parse my
| spam emails for IP addresses for processing of the spam.  I know I
| could do this in perl, but I want to do it with bash scripting for the
| experience...

No, you want to use "sh", not "bash". More portable. But for your
purposes, almost the same thing.

Try this:

  grep '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*' your-file

which should (untested!) match lines containing IPv4 addresses.
-- 
Cameron Simpson <[EMAIL PROTECTED]> DoD#743
http://www.cskk.ezoshosting.com/cs/

I am reminded of a memorable scene in "Falling Down", starring Michael
Douglas. In fact, I'm reminded of the whole damn movie, from glorious start
to amusing finish.  I nominate it as the official movie of alt.peeves.
        - mathew, [EMAIL PROTECTED]


To unsubscribe from this list, please email [EMAIL PROTECTED] & you will be 
removed. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/LINUX_Newbies/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/LINUX_Newbies/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to