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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-28-2005, 12:21 AM
|
#1
|
|
Senior Member
Registered: Apr 2003
Posts: 3,218
Rep:
|
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
|
|
|
|
06-28-2005, 01:26 AM
|
#2
|
|
Member
Registered: Jun 2005
Distribution: Debian
Posts: 356
Rep:
|
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?
|
|
|
|
06-28-2005, 01:33 AM
|
#3
|
|
Senior Member
Registered: Apr 2003
Posts: 3,218
Original Poster
Rep:
|
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
|
|
|
|
06-28-2005, 01:34 AM
|
#4
|
|
Member
Registered: Jun 2005
Distribution: Debian
Posts: 356
Rep:
|
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.
|
|
|
|
06-28-2005, 01:41 AM
|
#5
|
|
Senior Member
Registered: Apr 2003
Posts: 3,218
Original Poster
Rep:
|
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
|
|
|
|
06-28-2005, 01:45 AM
|
#6
|
|
Member
Registered: Jun 2005
Distribution: Debian
Posts: 356
Rep:
|
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.
|
|
|
|
06-28-2005, 02:41 AM
|
#7
|
|
Senior Member
Registered: Apr 2003
Posts: 3,218
Original Poster
Rep:
|
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
|
|
|
|
06-28-2005, 09:52 AM
|
#8
|
|
Member
Registered: Jun 2005
Distribution: Debian
Posts: 356
Rep:
|
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.
|
|
|
|
06-28-2005, 09:59 AM
|
#9
|
|
Senior Member
Registered: Apr 2003
Posts: 3,218
Original Poster
Rep:
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:29 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|