LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Flag question of Tar command (https://www.linuxquestions.org/questions/linux-general-1/flag-question-of-tar-command-337901/)

satimis 06-28-2005 12:21 AM

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

Noth 06-28-2005 01:26 AM

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?

satimis 06-28-2005 01:33 AM

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

Noth 06-28-2005 01:34 AM

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.

satimis 06-28-2005 01:41 AM

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

Noth 06-28-2005 01:45 AM

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.

satimis 06-28-2005 02:41 AM

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

Noth 06-28-2005 09:52 AM

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.

satimis 06-28-2005 09:59 AM

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


All times are GMT -5. The time now is 10:14 PM.