Grepping using multiple wildcards


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grepping using multiple wildcards
# 1  
Old 11-13-2008
Grepping using multiple wildcards

Is there anyway you can grep using multiple wildcards? When I run the below line the results return fine;

Code:
grep 12345 /usr/local/production/soccermatchplus/distributor/clients/*/out/fixtures.xml | awk -F/ '{print $8}'

However ideally, I need it to grep for;

Code:
grep 12345 /usr/local/production/soccermatchplus/distributor/clients/*/out/fix* | awk -F/ '{print $8}'

As there are variations in the filenames.

Thanks
JayC89
# 2  
Old 11-13-2008
Did you try it out yourself? Do you get an error or wrong results?
# 3  
Old 11-13-2008
Yes, in the 1st script it will list the client once. However in the 2nd the same client is listed multiple times as if it is in some sort of loop.

Any ideas?
JayC89
# 4  
Old 11-13-2008
I simply assume, that there are plenty of dirs and files under
Code:
/usr/local/production/soccermatchplus/distributor/clients/*

that are named
Code:
/out/fix*

You can also add a -l to the grep and keep the pipe into awk away so you can see which files have the pattern inside. If there are more than you expect, you either were wrong and the box is right, or you'll have to be more precise in which path you will search.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to handle grepping variable data containing wildcards?

I have a lot of files with keywords and unique names. I'm using a shell script to refer to a simple pattern file with comma separated values in order to match on certain keywords. The problem is that I don't understand how to handle the wildcard values when I want to skip over the unique names. ... (5 Replies)
Discussion started by: abercrom
5 Replies

2. Shell Programming and Scripting

Grep multiple patterns that contain wildcards

job_count=`grep -e "The job called .* has finished | The job called .* is running" logfile.txt | wc -l` Any idea how to count those 2 patterns so i have a total count of the finished and running jobs from the log file? If i do either of the patterns its works okay but adding them together... (8 Replies)
Discussion started by: finn
8 Replies

3. Shell Programming and Scripting

Grepping multiple strings from one column

I have 3-column tab separated data that looks like the following: act of+n-a-large+vn-tell-v 0.067427 act_com of+n+n-a-large-manufacturer-n 0.129922 act-act_com-com in+n-j+vn-pass-aux-restate-v 0.364499666667 com nmod+n-j+ns-invader-n 0.527521 act_com-com obj+n-a-j+vd-contribute-v 0.091413... (2 Replies)
Discussion started by: owwow14
2 Replies

4. Programming

Grepping a column from multiple file

I have 20 files that look pretty much like this: 0.01 1 3822 4.97379915032e-14 4.96982253992e-09 0 0.01 3822 1 4.97379915032e-14 4.96982253992e-09 0 0.01 2 502 0.00993165137406 993.165137406 0 0.01 502 2 0.00993165137406 993.165137406 0 0.01 4 33 0.00189645523539 189.645523539 0 0.01 33 4... (5 Replies)
Discussion started by: kayak
5 Replies

5. UNIX for Dummies Questions & Answers

Problems Grepping within multiple Quotes

Hello, I have a block of code (XML) that I would like to grep for certain information. The basic format of the XML is the following repeated a few hundred times, each time with a unique ID: <Identifier ID="A" NAME="John Doe" AGE="32 Years" FAMILY="4" SEX="MALE"></Identfier> I would like to... (6 Replies)
Discussion started by: jl487
6 Replies

6. Shell Programming and Scripting

Perl, open multiple files with wildcards

I have a question regarding Perl scripting. If I want to say open files that all look like this and assign them to a filehandle and then assign the filehandle to a variable, how do I do this? The file names are strand1.fa.gz.tmp strand2.fa.gz.tmp strand3.fa.gz.tmp strand4.fa.gz.tmp ...... (6 Replies)
Discussion started by: japaneseguitars
6 Replies

7. Shell Programming and Scripting

rename multiple files with wildcards

Hi All I am having hundred over file in the below pattern. AA050101.INI BB090101.INI . . ZX980101.INI Need to rename these files with an extension .bak AA050101.INI.bak BB090101.INI.bak . . ZX980101.INI.bak (5 Replies)
Discussion started by: karthikn7974
5 Replies

8. Shell Programming and Scripting

Grepping multiple terms with different arguments

Grep -e 'term1' -A1 -e 'term2' -A3The above code always searches for either term and prints results + next three lines. I'm trying to print out: foo foo foo term1 bar bar bar line right after the above -- la la la la term2 so so so line right after the above and again and again I've... (7 Replies)
Discussion started by: dkozel
7 Replies

9. Shell Programming and Scripting

Grepping Multiple Strings on the Same Line 'Or'

I've got this command that I've been using to find strings on the same line, say I'm doing a search for name: find . -name "*" | xargs grep -i "Doe" | grep -i "John" > output.txt This gives me every line in a file that has John and Doe in it. I'm looking to add a OR operator for the second... (5 Replies)
Discussion started by: Rally_Point
5 Replies

10. Shell Programming and Scripting

Trouble grepping for multiple strings

I am having a heck of a time trying to write a script that will grep for multiple strings in a single file. I am really at my wits end here and I am hoping to get some feedback here. Basic information: OS: Solaris 9 Shell: KSH Oracle Database server I was trying to grep through a file... (5 Replies)
Discussion started by: thecoffeeguy
5 Replies
Login or Register to Ask a Question