LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-17-2009, 09:44 PM   #1
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Rep: Reputation: 15
grep from bzipped file.


Hi

Is there any command to grep from a bzipped file? (like zgrep from gzipped file)
 
Old 05-18-2009, 12:31 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 97
Have you tried bzgrep?
 
Old 05-18-2009, 08:24 AM   #3
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 42.1_64+Tumbleweed-KDE, Mint 17.3
Posts: 4,023

Rep: Reputation: Disabled
You can always pipe it over to grep, i.e. "un-bzip <file> | grep <pattern>". Sorry, forgot the un-bzip command, Konqueror does that automatically .
 
Old 05-18-2009, 02:18 PM   #4
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 97
Quote:
Originally Posted by JZL240I-U View Post
You can always pipe it over to grep, i.e. "un-bzip <file> | grep <pattern>". Sorry, forgot the un-bzip command, Konqueror does that automatically .
To unzip you use the bunzip2 command, however you cannot pass that to grep as shown in your example. Additionally, the bunzip2 command would leave the file uncompressed.

bzgrep is the best option:
Code:
bzgrep "pattern" file
Alternatively use bzcat and pass the output to grep:
Code:
bzcat file|grep pattern
 
Old 05-19-2009, 01:10 AM   #5
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 42.1_64+Tumbleweed-KDE, Mint 17.3
Posts: 4,023

Rep: Reputation: Disabled
Quote:
Originally Posted by Disillusionist View Post
To unzip you use the bunzip2 command, however you cannot pass that to grep as shown in your example...
Ooops, why can't one pass the output of bunzip2 to grep? Normally when you don't specify an output file one should be able to catch the output via a pipe

<Edith says>: Okay, okay, you are right and I read the man page . bzip2 creates automatically outputfiles with an bz2 extension and vice versa.

Last edited by JZL240I-U; 05-19-2009 at 01:17 AM. Reason: got it
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grep file ust Linux - Newbie 4 03-06-2009 04:33 AM
grep for string in file after a certain part of the file B-Boy Programming 6 02-18-2009 07:49 AM
can't grep file ust Linux - Software 3 01-07-2008 06:03 AM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 04:56 AM
configuring apt-get to recognize bzipped pkglist and srclist files tanimislam Fedora 3 10-20-2004 01:53 PM


All times are GMT -5. The time now is 12:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration