Solved

find grep search-----string

Posted on 2004-08-22
5
649 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
  • 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
nodeip 9 68
Vmware Vswitch  VS  Redhat  Bridge 1 90
ftpcommand 2 50
recommend secure & efficient Unix LDAP (equiv of Windows AD) 6 83
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now