Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 663
  • Last Modified:

find grep search-----string

what is the best way to find a string that has a string in it but one of the words change in it, can't seem to find the right wildcard to use.

Ex:

need to find a sting line this:    rfc822;smith@my.domain.com

I want to find this sting but in this case take the word smith out and use a wild card in it's place to find any string that fits this with any user name that is before the @ in this string. I usally use grep but maybe i could do it better with find??
0
bt707
Asked:
bt707
  • 2
  • 2
1 Solution
 
jlevieCommented:
'grep -e "rfc822;.*@my.domain.com" some-file' should work.
0
 
bt707Author Commented:
I already tried with using the * in place of that word  but gives me nothing? that what I can't figure out.
0
 
jlevieCommented:
Note that I have .* in the regex expression, not just *

In a regex * matches 0 or more of the previous match and a . matches any character. So, .* matches a string of characters of any length. Since the regex has "rfc822;" before the .* and "@my.domain.com" after those limit the length of what .* can match.

Clear as mud now?
0
 
yuzhCommented:
grep "*pattern*" willl not work, you need to do:

grep "rfc822" filename(s) | grep "@my.domain.com"

0
 
bt707Author Commented:
got it work with the "."

Thanks,
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now