Solved

find grep search-----string

Posted on 2004-08-22
5
655 Views
Last Modified: 2013-12-27
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
Comment
Question by:bt707
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 11864095
'grep -e "rfc822;.*@my.domain.com" some-file' should work.
0
 

Author Comment

by:bt707
ID: 11864485
I already tried with using the * in place of that word  but gives me nothing? that what I can't figure out.
0
 
LVL 40

Accepted Solution

by:
jlevie earned 500 total points
ID: 11864628
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
 
LVL 38

Expert Comment

by:yuzh
ID: 11866586
grep "*pattern*" willl not work, you need to do:

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

0
 

Author Comment

by:bt707
ID: 11866675
got it work with the "."

Thanks,
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question