LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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-28-2005, 01:21 AM   #1
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Rep: Reputation: 53
Flag question of Tar command


Hi folks,

I have an tarball having following formats of files compressed, e.g.;

Group_A
package-01
package-02
package-03
etc.

Group_B
file-01.patch
file-02.patch
file-03.patch
etc.

What combination of flags have to be up so that files in Group_A will be directed to a new sub_directory_A and files in Group_B to another new sub_directory_B respectively. Both new sub_directories have to be created in executing tar command.

TIA

B.R.
satimis
 
Old 06-28-2005, 02:26 AM   #2
Noth
Member
 
Registered: Jun 2005
Distribution: Debian
Posts: 356

Rep: Reputation: 30
So you're saying that you have 2 groups of files in the root directory of a tar archive and you'd like them to be seperated into directories when you extract the archive?
 
Old 06-28-2005, 02:33 AM   #3
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53
Hi Noth,

Yes, you are right.

Sorry I overlooded and forgot to mention in my first posting that there are 3 gourps of files in the tarball, .patch files, packages and read files. I'm trying to mv all .patch files to ~/patches/ and the remaining files to ~/packages/ during extraction.

B.R.
satimis
 
Old 06-28-2005, 02:34 AM   #4
Noth
Member
 
Registered: Jun 2005
Distribution: Debian
Posts: 356

Rep: Reputation: 30
I don't think there's a way to do what you want, tar will just extract the files with the path information inside of the archive.
 
Old 06-28-2005, 02:41 AM   #5
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53
Hi Noth,

With '-C' flag all files extracted can be directed to a directory pre-created. However I'm trying to discover whether there are some other flags which can help sorting files during extraction other than using a command line.

B.R.
satimis
 
Old 06-28-2005, 02:45 AM   #6
Noth
Member
 
Registered: Jun 2005
Distribution: Debian
Posts: 356

Rep: Reputation: 30
You could use 3 seperate tar commands, when you tell tar to extract files you can give it a wildcard to have it only extract certain files. So you could script the directory creation and tar invocation.
 
Old 06-28-2005, 03:41 AM   #7
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53
Hi Noth,

Tks for your advice.

Quote:
You could use 3 seperate tar commands..
Can I apply following command line to do it;

Code:
tar xvf --exclude FILE .patch tarball -C ~/packages/ | tar xvf -exclude FILE .bz2 .tar .tgz .(read file???) tarball -C ~/patches/
How to filter the read files? Beside is there any way to repeat "tar" command in stead of entering "tar xvf" twice.

TIA

B.R.
satimis
 
Old 06-28-2005, 10:52 AM   #8
Noth
Member
 
Registered: Jun 2005
Distribution: Debian
Posts: 356

Rep: Reputation: 30
Why not just run the 3 tar commands seperately? It's a script, you only have to type it out once and doing it your way is just complicating things for no reason so if you ever have to go back and change it you'll be scratching your head wondering wtf you were trying to o.
 
Old 06-28-2005, 10:59 AM   #9
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53
HI Noth,

Quote:
Why not just run the 3 tar commands seperately?....
I'm trying to learn something new to me as well as the options of 'tar' command. In fact it is quite simple to do it, just extracting the tarball and moving the files around in "Konqueror/home".

B.R.
satimis
 
  


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
a tough question 4 u, problem in extracting tar & tar.gz files p_garg Linux - General 5 11-08-2010 12:02 PM
mkisofs - flag question satimis Linux - Software 2 10-08-2005 09:38 AM
Cdrecord - flag question satimis Linux - General 1 05-27-2005 04:49 AM
Tar command question satimis Linux - General 2 05-21-2005 08:05 PM
tar command question American Psycho Linux - General 3 04-18-2004 10:21 PM


All times are GMT -5. The time now is 01:58 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration