List Info

Thread: Gnu Tar: Extracting files into a single directory




Gnu Tar: Extracting files into a single directory
user name
2006-06-20 10:09:03
Pascal Bourguignon wrote:
> Dubious Dude <Shiftyeyes.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.
_______________________________________________
help-gnu-utils mailing list
help-gnu-utilsgnu.org

http://lists.gnu.org/mailman/listinfo/help-gnu-utils
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )