LinuxQuestions.org
Help answer threads with 0 replies.
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 07-27-2014, 07:19 AM   #1
postcd
Member
 
Registered: Oct 2013
Posts: 531

Rep: Reputation: Disabled
List tar contents only first level, then subdirectory & extract


Hello,

thanks for Your visit, i want to ask for advice with linux Tar.

I know i can list tar contents by command: tar tf archive.tar
If its tar.gz, i can: tar tzf archive.tar.gz

But my tar.gz is 40Gb large and its whole linux filesystem.

please kindly advice me on how i can list only arcive root directory. Then i see folder name that interest me, then how i can list only that folder contents (non recursivelly) and this way browse deep into archive. Then how i can extract example folder or file /archive.tar.gz/folder/subfolder/fileorfolder

Please can You write commands?

Thank you alot

Last edited by postcd; 07-27-2014 at 07:21 AM.
 
Old 07-27-2014, 09:33 PM   #2
abethelmy
LQ Newbie
 
Registered: Jul 2012
Posts: 7

Rep: Reputation: Disabled
Thumbs up Should address your first level issue.

I would try:

$ tar -tf archive.tar.gz | grep -E '^\w+(\.\w+)*/*\w+(\.\w+)*/?$'

The tar command should autodetect that it's a *.gz file.
 
Old 07-27-2014, 10:33 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,797

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
This is a case where a GUI archive manager would be a far better choice, as it can do all the things you mentioned quite naturally, and without having to re-read the entire 40 GB archive (a tar archive does not have a centralized directory) every time you found something interesting to look at more deeply.
 
Old 07-29-2014, 09:17 AM   #4
postcd
Member
 
Registered: Oct 2013
Posts: 531

Original Poster
Rep: Reputation: Disabled
Quote:
tar -tftf vzdump-1050.tgz | grep -E '^\w+(\.\w+)*/*\w+(\.\w+)*/?$'
result in no result. i mean command finish and nothin is printed to stdout

this worked, but still lsit all files recursivelly subdirectories etc..:
Quote:
tar --list --verbose --no-recursion --file=vzdump-1050.tgz ./usr/*
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] bash script to list tar files in directory and then extract based on user's input socalheel Programming 12 09-23-2013 10:24 AM
TAR subdirectory question duffsterlp Linux - Newbie 8 07-20-2010 04:41 PM
How to list contents of a .tar.gz without unzip? leontini Linux - General 14 04-21-2010 03:07 AM
Clear contents of directory if 45 days old, but exclude specific subdirectory? agi93 Slackware 6 02-05-2010 05:19 PM
Apache 2.0, I want to list dir contents & password protect... Scrag Linux - Software 3 02-10-2005 12:38 PM

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

All times are GMT -5. The time now is 10:30 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
Open Source Consulting | Domain Registration