HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to do a find on the gzipped files
Operating System - HP-UX
1834640
Members
3277
Online
110069
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2007 04:26 AM
04-06-2007 04:26 AM
How to do a find on the gzipped files
There are number of gzipped log files which I need to search for a text , how shall I search these files without gunzipping them.
thanks,
hunki
thanks,
hunki
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2007 04:31 AM
04-06-2007 04:31 AM
Re: How to do a find on the gzipped files
Hi Hunki:
This should work.
# find /path -xdev -type f -name "*.gz" | xargs -n1 -t gzip -d -c | grep pattern
For example, given '/tmp/hosts.gz' and '/tmp/services.gz' --- copies of the standard files, gzipped:
# find /tmp -xdev -type f -name "*.gz" | xargs -n1 -t gzip -d -c |grep local
...produces:
gzip -d -c /tmp/hosts.gz
127.0.0.1 localhost loopback
gzip -d -c /tmp/services.gz
hacl-local 5304/tcp # HA Cluster Commands
...by using the trace option of 'xargs' and processing one argument at a time ('-n 1') we can show the filename in which the match occurs. Your files are only uncompressed on-the-fly. They are left unchanged on disk.
Regards!
...JRF...
This should work.
# find /path -xdev -type f -name "*.gz" | xargs -n1 -t gzip -d -c | grep pattern
For example, given '/tmp/hosts.gz' and '/tmp/services.gz' --- copies of the standard files, gzipped:
# find /tmp -xdev -type f -name "*.gz" | xargs -n1 -t gzip -d -c |grep local
...produces:
gzip -d -c /tmp/hosts.gz
127.0.0.1 localhost loopback
gzip -d -c /tmp/services.gz
hacl-local 5304/tcp # HA Cluster Commands
...by using the trace option of 'xargs' and processing one argument at a time ('-n 1') we can show the filename in which the match occurs. Your files are only uncompressed on-the-fly. They are left unchanged on disk.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2007 08:56 PM
04-07-2007 08:56 PM
Re: How to do a find on the gzipped files
You can also use gzcat
find . -name '*gz' -exec /usr/contrib/bin/gzcat {} \;|grep thestring
gzcat filename.gz|grep thestring
If /usr/contrib/bin is in your path you can just use gzcat. Also you can use it with the xargs option mentioned above by James.
Regards,
Rasheed Tamton.
find . -name '*gz' -exec /usr/contrib/bin/gzcat {} \;|grep thestring
gzcat filename.gz|grep thestring
If /usr/contrib/bin is in your path you can just use gzcat. Also you can use it with the xargs option mentioned above by James.
Regards,
Rasheed Tamton.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2007 10:54 PM
04-07-2007 10:54 PM
Re: How to do a find on the gzipped files
This might be more suitable if you have more zipped files to search
for i in `find /tmp -name "*gz"`
do
echo $i
/usr/contrib/bin/gzcat $i|grep string
done
Change /tmp (dir name) according to your find requirement.
Regards,
Rasheed Tamton.
for i in `find /tmp -name "*gz"`
do
echo $i
/usr/contrib/bin/gzcat $i|grep string
done
Change /tmp (dir name) according to your find requirement.
Regards,
Rasheed Tamton.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP