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 |
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?
|
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 |
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.
|
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 |
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.
|
Hi Noth,
Tks for your advice. Quote:
Code:
tar xvf --exclude FILE .patch tarball -C ~/packages/ | tar xvf -exclude FILE .bz2 .tar .tgz .(read file???) tarball -C ~/patches/ TIA B.R. satimis |
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.
|
HI Noth,
Quote:
B.R. satimis |
All times are GMT -5. The time now is 10:14 PM. |