Thread View: comp.unix.questions
5 messages
5 total messages
Started by Dubious Dude
Mon, 19 Jun 2006 11:10
Gnu Tar: Extracting files into a single directory
Author: Dubious Dude
Date: Mon, 19 Jun 2006 11:10
Date: Mon, 19 Jun 2006 11:10
11 lines
1418 bytes
1418 bytes
Hello, I want to extract a number of files from a tar.gz archive. I want to extract them all into a single directory, regardless of their path in the archive. I haven't found a switch in the gnu manual for this. Is it possible? I realize I can extract them into the directories as per their full path, then move them to a common directory. But if gnu can extract them into the common directory, I use that feature of course. Thanks.
Re: Gnu Tar: Extracting files into a single directory
Author: Pascal Bourguignon
Date: Mon, 19 Jun 2006 12:55
Date: Mon, 19 Jun 2006 12:55
24 lines
2204 bytes
2204 bytes
Dubious Dude <Shifty@eyes.com> writes:
> I want to extract a number of files from a tar.gz archive.
> I want to extract them all into a single directory, regardless
> of their path in the archive. I haven't found a switch in the
> gnu manual for this. Is it possible? I realize I can extract
> them into the directories as per their full path, then move
> them to a common directory. But if gnu can extract them into
> the common directory, I use that feature of course.
But you can flatten the result with (untested):
tar -C output -zxf archive.tar.gz
cd output
find . -type f -exec mv -i {} . \;
find * -type d -prune -exec rm -rf {} \;
--
__Pascal Bourguignon__ http://www.informatimago.com/
HEALTH WARNING: Care should be taken when lifting this product,
since its mass, and thus its weight, is dependent on its velocity
relative to the user.
Re: Gnu Tar: Extracting files into a single directory
Author: Sven Mascheck
Date: Mon, 19 Jun 2006 18:20
Date: Mon, 19 Jun 2006 18:20
23 lines
1149 bytes
1149 bytes
Dubious wrote: > tar.gz archive. I want to extract them all into a single directory, > regardless of their path in the archive. $ zcat archive.tar.gz | pax ./ ./dir/ ./dir/subdir/ ./dir/subdir/b ./dir/subdir/a ./dir/a $ zcat archive.tar.gz | pax -r -s ',.*/,,p' ./ >> ./dir/ >> ./dir/subdir/ >> ./dir/subdir/b >> b ./dir/subdir/a >> a ./dir/a >> a $ ls a b
Re: Gnu Tar: Extracting files into a single directory
Author: Dubious Dude
Date: Tue, 20 Jun 2006 10:09
Date: Tue, 20 Jun 2006 10:09
19 lines
1752 bytes
1752 bytes
Pascal Bourguignon wrote:
> Dubious Dude <Shifty@eyes.com> writes:
>> I want to extract a number of files from a tar.gz archive.
>> I want to extract them all into a single directory, regardless
>> of their path in the archive. I haven't found a switch in the
>> gnu manual for this. Is it possible? I realize I can extract
>> them into the directories as per their full path, then move
>> them to a common directory. But if gnu can extract them into
>> the common directory, I use that feature of course.
>
> But you can flatten the result with (untested):
>
> tar -C output -zxf archive.tar.gz
> cd output
> find . -type f -exec mv -i {} . \;
> find * -type d -prune -exec rm -rf {} \;
Thank you, Pascal. I was thinking about "find" for the case
where a suitable switch is not available for tar.
Re: Gnu Tar: Extracting files into a single directory
Author: Dubious Dude
Date: Tue, 20 Jun 2006 10:24
Date: Tue, 20 Jun 2006 10:24
29 lines
1829 bytes
1829 bytes
Sven Mascheck wrote: > Dubious wrote: > >> tar.gz archive. I want to extract them all into a single directory, >> regardless of their path in the archive. > > $ zcat archive.tar.gz | pax > ./ > ./dir/ > ./dir/subdir/ > ./dir/subdir/b > ./dir/subdir/a > ./dir/a > > $ zcat archive.tar.gz | pax -r -s ',.*/,,p' > ./ >> > ./dir/ >> > ./dir/subdir/ >> > ./dir/subdir/b >> b > ./dir/subdir/a >> a > ./dir/a >> a > > $ ls > a b Thank you, Sven. I'll keep that in mind for when pax is available. I know from the cygwin mailing list that this is possible, even through it doesn't come with cygwin itself.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads