Solved

find grep search-----string

Posted on 2004-08-22
5
656 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

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

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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

687 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