|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
zgrep for multiple exact matches
I have a few gigs of *.gz files and I want to extact a list of IP addresses from it. The command I am using is kind of working but it is not extracting the exact results. For example, I have been using the follwing command; Code:
zgrep --no-filename -e 10.0.0.9 -e 10.0.0.15 -e 10.0.0.244 -e 10.0.0.18 -e 10.0.0.200 -e 10.0.0.111 -e 10.0.0.18 *.gz > outputfile.out But I noticed in the output file it will also include addresses additional to my request. For example if I specify 10.0.0.9 with -e it will also output 10.0.0.90. How can I structure my command to extract the exact input data? |
| Sponsored Links | |
|
|
|
#2
|
||||
|
||||
|
If the lines end with the IP address, then you can try this... Code:
zgrep -e "10.0.0.9$" *.gz If not, show us how the line looks like... --ahamed |
| Sponsored Links | ||
|
|
|
#3
|
||||
|
||||
|
Try word matching Code:
zgrep -w -F -f random_ip.txt *.gz does your grep support -o ? Code:
zgrep -w -o -F -f random_ip.txt *.gz |
|
#4
|
|||
|
|||
|
Quote:
This method works by reading from a list of IP addresses that you want to grep; zgrep -w -F -f iplist.txt *.gz > iplist.out |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Changing exact matches with awk from subfields | adamreiswig | Shell Programming and Scripting | 4 | 01-24-2012 04:29 PM |
| grep multiple matches | santonio | UNIX for Dummies Questions & Answers | 2 | 01-29-2011 06:32 AM |
| Using grep returns partial matches, I need to get an exact match or nothing | TKD | Shell Programming and Scripting | 3 | 01-25-2011 11:52 AM |
| Multiple arguments passed to zgrep in sh/ksh | linux_lou | Programming | 1 | 02-09-2010 02:29 PM |
| Does Sed Search/Replace Work For Multiple Matches On The Same Line? | cibalo | Shell Programming and Scripting | 3 | 06-06-2009 03:38 AM |
|
|