|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to perform Grep on many Gzip files, Searching for Specific information
Hello,
I am wondering if you can assist with my question and ask kindly for this. I have a number of files that are listed as file1.gz through file100.gz. I am trying to perform a grep on the files and find a specific date that only resides within within one of the files. There are multiple entries within the file so I am try to also limit the amount of output with the tail or head command. My command is something like this, although it is incorrect: gunzip -c file1.*.gz |grep -v "Jul 25 22:16:09" | tail -n 20 Thank you kindly. |
| Sponsored Links | ||
|
|
|
#2
|
|||
|
|||
|
You want the name of the file that has Jul 25 22:16:09 in it correct? Code:
for filename in file*.gz
do
gunzip $filename | grep -q 'Jul 25 22:16:09'
if [[ $? -eq 0 ]] ; then
echo $filename
break
fi
done |
|
#3
|
|||
|
|||
|
You might look at zgrep to simplify your answer (assuming it's available on your platform) Code:
zgrep "Jul 25 22:16:09" file1.*.gz | tail -n 20 More info: The Power of Z Commands – Zcat, Zless, Zgrep, Zdiff Examples zgrep(1) - Linux man page |
|
#4
|
|||
|
|||
|
Thanks much to those that responded.
Will try what was suggested and advise. Best regards. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perform a set of actions for a specific file type | oehtus | Shell Programming and Scripting | 2 | 06-15-2009 11:07 AM |
| Searching for package information on Debian and Ubuntu systems | Linux Bot | UNIX and Linux RSS News | 0 | 10-28-2008 10:20 AM |
| grep - searching for a specific string | manthasirisha | Shell Programming and Scripting | 2 | 01-05-2006 08:24 AM |
| searching text files on specific columns for duplicates | Gerry405 | UNIX for Dummies Questions & Answers | 2 | 08-18-2005 10:51 AM |
| Searching for a specific string in an argumnet | dinplant | Shell Programming and Scripting | 1 | 03-11-2002 02:28 PM |