Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rating: Thread Rating: 9 votes, 5.00 average. Display Modes
Old 10-19-2007, 11:38 AM   #1
cocotu
Triple-A Player
 
Join Date: Mar 2007
Posts: 200
how to view the contents of a .tgz file without uncompressing?

is there a way (command) to see the contents of a .tgz file at the command line?

thanks
__________________
Mac OS X Leopard.
cocotu is offline   Reply With Quote
Old 10-19-2007, 11:41 AM   #2
baf
MVP
 
Join Date: Jun 2007
Location: Skellefteċ, Sweden
Posts: 1,173
tar ztf filename

will give a long list....

smarter

tar ztf filename |less
__________________
/Bengt-Arne Fjellner IT-Administrator Luleċ university, Sweden.
Some say: "You learn as long as you live".
My way: "You live as long as you learn".
baf is offline   Reply With Quote
Old 10-19-2007, 11:55 AM   #3
cocotu
Triple-A Player
 
Join Date: Mar 2007
Posts: 200
thanks baf! is there a way of just viewing the main directories NOT everything in them? I have around 20 directories (198GB) I don't want to wait for hours to see if the backup completed successful. I made a log file, but I see at the end:

tar(17186) malloc: *** vm_allocate(size=8421376) failed (error code=3)
tar(17186) malloc: *** error: can't allocate region
tar(17186) malloc: *** set a breakpoint in szone_error to debug
tar(17186) malloc: *** vm_allocate(size=8421376) failed (error code=3)
tar(17186) malloc: *** error: can't allocate region
tar(17186) malloc: *** set a breakpoint in szone_error to debug
tar: memory exhausted

Not sure if everything is there?
__________________
Mac OS X Leopard.
cocotu is offline   Reply With Quote
Old 10-19-2007, 01:28 PM   #4
blb
All Star
 
Join Date: Jan 2002
Location: CO, USA
Posts: 908
You can grep for just directories:
Code:
gunzip -c mytarfile.tar.gz | tar tvf - |grep "^d" |more
(Yeah, I still use the old-style gunzip|tar style). The grep is the important part, looking just for directories.
blb is offline   Reply With Quote
Old 10-19-2007, 02:13 PM   #5
cocotu
Triple-A Player
 
Join Date: Mar 2007
Posts: 200
thanks blb!! that worked, but maybe I didn't explain myself, I'm sorry. for example I have:

Volumes/DataHD/projects/adc/adc002_Hard_Launch/dt/html module pr
ototypes/OfficeLocator/trunk/images/_svn/prop-base/

then directory that I'm tarring is the projects directory. Is there a way to view the subdirectory right after projects/in this case the /adc? I have around 20 more subdirectories and I don't want to go thru the whole list of subdirectories. The command you gave me is very useful too. thanks!
__________________
Mac OS X Leopard.
cocotu is offline   Reply With Quote
Old 10-19-2007, 06:26 PM   #6
blb
All Star
 
Join Date: Jan 2002
Location: CO, USA
Posts: 908
Sure, just chain another grep in there:
Code:
... |grep "^d"|grep "projects/adc" |more
should show only directories which have projects/adc in them.
blb is offline   Reply With Quote
Old 10-22-2007, 11:47 AM   #7
cocotu
Triple-A Player
 
Join Date: Mar 2007
Posts: 200
thanks blb, it works! how about when that particular folder is not in the .tgz file what is supposed to happen? No output at all? I'm looking for a directory, its being 15min. and still no output. thanks
__________________
Mac OS X Leopard.
cocotu is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 12:39 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.