- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Grep a tar.gz file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- 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-26-2004 02:43 AM
тАО04-26-2004 02:43 AM
Grep a tar.gz file
I'd like to grep for an IP within this monster file on the fly without unzipping and untarring it in separate steps...
is there a way to grep an IP out of this log file in one command that will leave the tar.gz file in place while temporarily inflating to search the text?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2004 07:57 AM
тАО04-26-2004 07:57 AM
Re: Grep a tar.gz file
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2004 08:03 AM
тАО04-26-2004 08:03 AM
Re: Grep a tar.gz file
tar zxvf tar.gz |grep ip
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2004 08:06 AM
тАО04-26-2004 08:06 AM
Re: Grep a tar.gz file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2004 08:09 AM
тАО04-26-2004 08:09 AM
Re: Grep a tar.gz file
.... tar: z: unknown option. tar: usage tar {txruc}[eONvVwAfblhm{op}][0-7[lmh]] [tapefile] [blocksize] [[-C directory] file] ...
I'm guessing "z" don't work ;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2004 08:12 AM
тАО04-26-2004 08:12 AM
Re: Grep a tar.gz file
http://hpux.ee.ualberta.ca/hppd/hpux/Gnu/tar-1.13.25/
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2004 08:29 AM
тАО04-26-2004 08:29 AM
Re: Grep a tar.gz file
tar zxf - tar.gz | grep ip
Of course, without GNU tar and having the log file tar'd anyway, I believe you can still accomplish the same thing with
gzcat tar.gz | tar xf - | grep ip
At least I think I got that syntax correct. It's proving to be a long day. :)
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2004 10:02 AM
тАО04-26-2004 10:02 AM
Re: Grep a tar.gz file
# gzip -d < file.tar.gz | grep pattern
that's because tar does store the files unmodified. Same for GNU tar, which you don't need here.
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2004 10:08 AM
тАО04-26-2004 10:08 AM
Re: Grep a tar.gz file
Doing a tar zxf file | grep ip will not work since tar (or even gnu tar) will restore content, not display the contents of an archived file.
If the tar archive truly only contains your one log file, then it would be better to just compress the log file and not deal with tar.
Then you could do a command like-
zcat mylogfile.Z | grep 10.10.10.10
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2004 12:01 PM
тАО04-26-2004 12:01 PM
Re: Grep a tar.gz file
gzip -cd file.tar.gz | tar xvf - | grep
But this does pretty much the same as what Merijn said.
But as has already been said, why 'tar' a single file? The whole point of 'tar' (tape archive) is to concatenate multiple-files into a single-file stream good for outputting to a tape device. The basic syntax is very similar to 'ar', used for making static-link libraries and other basic archive files.
Anybody know the history of the two, code wise?
Anyway, getting side tracked..
Admittadly not many use it for that purpose any more as there are much better backup routines/commands available, but instead use it to dump to a local filesystem, thus the '.tar' file ;)