Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

find grep search-----string

Posted on 2004-08-22
5
Medium Priority
?
660 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

610 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