How to view the contents of .gz file without extracting the file? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

How to view the contents of .gz file without extracting the file?

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-13-2008
amitkhiare amitkhiare is offline
Registered User
 
Join Date: Feb 2006
Last Activity: 21 October 2009, 8:26 PM EDT
Location: Hong Kong
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Error How to view the contents of .gz file without extracting the file?

Hi All,

I have several .gz files and i need to see the contents of these file, without extracting these file. If i extract these file the space will be full so. I need to see the contents and parse the contents to a script to extract data from these.

Please let me know if you need any more information.

thanks and regards,
Amit
Sponsored Links
    #2  
Old 01-13-2008
ghostdog74 ghostdog74 is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 31 October 2014, 9:25 PM EDT
Posts: 2,669
Thanks: 0
Thanked 18 Times in 18 Posts
try zcat , if you have it.
Sponsored Links
    #3  
Old 01-13-2008
amitkhiare amitkhiare is offline
Registered User
 
Join Date: Feb 2006
Last Activity: 21 October 2009, 8:26 PM EDT
Location: Hong Kong
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
zcat is used for compressed file. These are zip files. Also i dont wante to see the file name, but i need to read the zip file.

for example:-

the zip file is a.gz, however the orginial file inside is a.txt.

I want to see wht is there in a.txt and pipe it to another file and use that somewhere else.

Assumming the data in a.txt is 12368464,ffg,afasdffads,3243,dfdarf

so i need to know wht is in the a.txt

Hope now the requirement is clear.

Thanks,
amit
    #4  
Old 01-13-2008
amitkhiare amitkhiare is offline
Registered User
 
Join Date: Feb 2006
Last Activity: 21 October 2009, 8:26 PM EDT
Location: Hong Kong
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
FYI......

I got it sort

Command is : gzip -cd <file> | more
Sponsored Links
    #5  
Old 12-02-2008
sridharg sridharg is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 30 December 2008, 6:10 AM EST
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
@ Command is : gzip -cd <file> | more
This command works in case of single file in the archive... if there are multiple files in archive rest of the file are skipped...

I get this message:

"gzip: test.zip has more than one entry--rest ignored"

Any suggestions to extract specific file from a zip archive with multiple files?
Sponsored Links
    #6  
Old 12-02-2008
pareshan pareshan is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 5 May 2009, 4:24 PM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
I think you simply can do
tar tf file_name

Coz i use tht for all .tgz (tar files) and it works
Sponsored Links
    #7  
Old 12-17-2008
tosattam tosattam is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 12 February 2010, 10:05 AM EST
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Hi I have a problem. I have a .GZ file say tosattam.GZ
If I unzip the file using winzip in windows the extract comes out as asd_123.txt
but when i am trying gunzip or gzip -d after bringing the file in UNIX I am getting tosattam as the extract from the same .GZ file. The one I am getting in windows is correct I know. But why am I not getting the same in UNIX??!!
totally confused
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Replace partial contents of file with contents read from other file seeki Shell Programming and Scripting 2 03-12-2012 06:54 AM
I want to delete the contents of a file which are matching with contents of other file ranasheel2000 Shell Programming and Scripting 3 09-02-2011 08:15 AM
Help with searching for a file in a directory and copying the contents of that file in a new file zel2zel UNIX for Dummies Questions & Answers 6 03-05-2011 12:44 PM
Matching two file contents and extracting associated information newpro Shell Programming and Scripting 2 07-02-2010 12:04 PM
compare 2 file contents , if same delete 2nd file contents krishnampkkm UNIX for Dummies Questions & Answers 5 03-08-2010 03:18 AM



All times are GMT -4. The time now is 09:12 AM.