Find the answer to your Linux question:
Results 1 to 4 of 4
Can someone help me with my grep command? I need to match ANYTHING with a wild card to match any pathern. I played with regex but couldnt get it it ...
  1. #1
    Just Joined!
    Join Date
    Jan 2005
    Location
    Toronto, Canada
    Posts
    7

    grep help

    Can someone help me with my grep command?

    I need to match ANYTHING with a wild card to match any pathern. I played with regex but couldnt get it it work.

    grep "Delivery of nonspam" mail | grep "to ANYTHING#harper" | more

    Thank you

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,970
    grep/egrep use regex expressions for pattern matchine. In your example, try this:
    Code:
    # note the use of -i to force grep to be case-insensitive
    # also not the use of single quotes so the shell doesn't expand the wild-cards
    grep -i 'delivery of nonspam' mail | grep -i 'to .*#harper' | less
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Jan 2005
    Location
    Toronto, Canada
    Posts
    7
    Quote Originally Posted by Rubberman View Post
    grep/egrep use regex expressions for pattern matchine. In your example, try this:
    Code:
    # note the use of -i to force grep to be case-insensitive
    # also not the use of single quotes so the shell doesn't expand the wild-cards
    grep -i 'delivery of nonspam' mail | grep -i 'to .*#harper' | less
    You rock! I was wondering why regex didn't work with double quotations. Tons of thanks!

  4. #4
    Just Joined!
    Join Date
    Dec 2010
    Posts
    16
    there's a website only about regex and its very amazing. I learnd alot with it, take a look: regular-expressions.info

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...