Operating System - HP-UX
1834050 Members
2143 Online
110063 Solutions
New Discussion

One simple question about tar

 
huanglsh_1
New Member

One simple question about tar

I just want to know how to extract certain dir of file from a .tar file.
i.e. tar xvf /dev/dat
This can extract the file from tape. But if I want to do the same thing from a tar file. i.e
tar xvf /tmp/abc.tar .
It doesn't work.
3 REPLIES 3
huanglsh_1
New Member

Re: One simple question about tar

I just check this method, it is alright for .tar file. Maybe I make a misktake when inputing the cmd. Soory to disturb your all.
Dan Hetzel
Honored Contributor

Re: One simple question about tar

Hi,

The main difficulty when trying to extract a file with tar comes from the way the file is stored in the archive. ie absolute versus relative path.

To meke sure, first inventory your archive with 'tar tvf tarfile', search for your file name and use it as is in the 'tar xvf' command.

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Carlos Fernandez Riera
Honored Contributor

Re: One simple question about tar

Yes, first take a look with tar tvf

then tar xvf file.tar

if is:

/tmp/dir tar extracts directory and files
/tmp/dir/ tar extracts only directory
file might no contain metacharacters (*,?)
unsupported