LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-15-2016, 03:06 PM   #1
mia_tech
Member
 
Registered: Dec 2007
Location: FL, USA
Distribution: CentOS 5.3, Ubuntu 9.04
Posts: 245

Rep: Reputation: 16
how can I list tar.gz file recursively


I have a tar.gz file in a remote server and I want to be able to list its content recursively. I know I can use
Code:
tar -vtf mydocs.tar.gz
myDocs/
myDocs/book1.pdf
myDocs/book2.pdf
myDocs/pictures/
myDocs/homework.odt
myDocs/class/
myDocs/book3.pdf
myDocs/finalPaper.odt
but that only list one level down. I have sub-directories class/ and pictures/ that contain data and I can't get the content listed... how can I do that?
 
Old 06-15-2016, 04:52 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by mia_tech View Post
I have sub-directories class/ and pictures/ that contain data and I can't get the content listed
That archive doesn't have any class/ or pictures/ directories in it.
How was it made and can it be re-made?

Create archive:
Code:
tar czvf file.tar.gz /etc/fail2ban/ /etc/apache2/ /path/to/one/file.ext
NOTE: Won't work for you. Just a teachable moment.

# file.tar.gz is the name (and optionally path) of the archive being created.
# /etc/fail2ban/ /etc/apache2/ /path/to/one/file.ext are paths to include in file.tar.gz
# a trailing slash indicates a directory/

Test archive:
Code:
tar ztf file.tar.gz
Search archive:
Code:
tar ztf file.tar.gz | grep <thing>
Extract archive:
Code:
tar zxf file.tar.gz
Extract thing:
Code:
tar zxf file.tar.gz| grep <thing>

Last edited by Habitual; 06-15-2016 at 04:56 PM.
 
Old 06-15-2016, 05:40 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213
The command "tar -vtf mydocs.tar.gz" will list everything that is in that archive. If that is really the complete command that you are using, then the directories "myDocs/pictures/" and "myDocs/class/" are empty. Did you perhaps have top-level directories "pictures/" and "class/" that you didn't include in the archive?
 
  


Reply

Tags
gz, list, tar



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to list all file types recursively? dahweeds Programming 5 08-16-2012 01:54 PM
How to list all files recursively, in a non-broken list? nyle Linux - Newbie 1 12-16-2008 10:52 PM
list files in a tar.gz file linuxtesting2 Linux - Newbie 4 09-23-2004 02:49 AM
can not list tar file juno Linux - Software 2 09-23-2002 02:47 AM
can not list tar file juno Linux - General 2 09-22-2002 11:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:50 PM.

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
Open Source Consulting | Domain Registration