TAR help .....

Bill Campbell linux-sxs at celestial.com
Thu Jan 22 13:05:36 PST 2009


On Fri, Jan 23, 2009, james at jamesmcdonald.id.au wrote:
>> Ok, I have a tar file. When you tzr tvzf , you have a list that shows
>> something
>> like :
>> ....
>> ......
>> export/usr1/thisdir/afile
>> export/usr1/thisdir/MYFILE
>> .....
>> ......
>> ....... (and so one ..)
>>
>> and you want to extract ONLY MYFILE and you want it extracted
>> in the directory you are in and NOT the WHOLE tree
>> How do you do that ?
>>
>
>Basic syntax is:
>tar -xzf foo.tar.gz blah.txt
>              extract the file blah.txt from foo.tar.gz
>
>but...
>if you have.
>
>usr1/MYFILE
>usr1/thisdir/MYFILE
>
>it will probably extract both MYFILE's

I think it only extracts the pathname as it is found in the tar
file, not all files that match the basename.

>but I think you can specify it using a relative path
>tar -xzf foo.tar.gz thisdir/MYFILE

gnu-tar also has ``-C directory'' or ``--directory=directory''
that, like the same option to gnu-make, changes to the specified
directory before starting the extraction.  This can be very handy
in scripts to avoid having to keep track of the current directory.

Bill
-- 
INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
Voice:          (206) 236-1676  Mercer Island, WA 98040-0820
Fax:            (206) 232-9186

Windows is a computer virus with a user interface!!



More information about the Linux-users mailing list