Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

extract single file without read all tar

7 views
Skip to first unread message

tmp123

unread,
May 24, 2007, 8:47:16 AM5/24/07
to
Hello,

Thanks for your time,

If a single file is extracted from a .tar file (by example, with "tar -
xvf foo.tar bar.txt") the full .tar file is read, independent if the
file is at start, middle or end of file.

Please, there are any way to seek directly to the file start, dump it,
and exit? If not with tar, it is possible with any other archiver or
compressor (cpio, rar, gzip, bzip2, ...)

The archive fill be stored in disk, thus, seek will be possible.

Thanks again.

Tim Bradshaw

unread,
May 24, 2007, 9:58:54 AM5/24/07
to
On May 24, 1:47 pm, tmp123 <tmp...@menta.net> wrote:

> Please, there are any way to seek directly to the file start, dump it,
> and exit? If not with tar, it is possible with any other archiver or
> compressor (cpio, rar, gzip, bzip2, ...)

Not with tar, no.

Message has been deleted

Darren Dunham

unread,
May 24, 2007, 12:47:12 PM5/24/07
to
tmp123 <tmp...@menta.net> wrote:

> If a single file is extracted from a .tar file (by example, with "tar -
> xvf foo.tar bar.txt") the full .tar file is read, independent if the
> file is at start, middle or end of file.

> Please, there are any way to seek directly to the file start, dump it,
> and exit? If not with tar, it is possible with any other archiver or
> compressor (cpio, rar, gzip, bzip2, ...)

Tar doesn't do so itself. You'd need to keep track of that information
separately and feed tar just the section of the file that you want.

This is basically what NetBackup does. When you want one file out of a
backup, it forwards the tape to just before where it needs, then sends
tar a section of the data. Something like this...

dd if=/big/huge.tar iseek=<start> count=<size> | tar xf -

Start is the number of blocks forward to seek, which should be just less
than the location of the file. Count is the number of blocks to pass,
which should be greater than the actual size of the file in question.

Gnu tar can handle reading from the middle of a tar stream. I don't
know if stock Solaris tar will do so.

The disadvantage here is that you have to maintain the record of where
all this stuff is. 'tar' doesn't have any indexing capabilities to do
it for you.

--
Darren Dunham ddu...@taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >

Kjetil Torgrim Homme

unread,
May 25, 2007, 9:48:19 AM5/25/07
to
[tmp123]:

>
> If a single file is extracted from a .tar file (by example, with
> "tar - xvf foo.tar bar.txt") the full .tar file is read,
> independent if the file is at start, middle or end of file.

tar is short for Tape ARchive, and you can tell this from the format.
there is no header listing the files contained inside, the
metainformation is added in front of each included file. also, it is
possible to *add* to a tar-file, including a file which already
exists. in that case, the file coming last has precedence. this is
why it has to read the complete file, even if the file you're
interested in comes first.

> Please, there are any way to seek directly to the file start, dump it,
> and exit? If not with tar, it is possible with any other archiver or
> compressor (cpio, rar, gzip, bzip2, ...)

rar and zip support random access. I wouldn't recommend rar, though,
since it's not a very open format. of course neither of them will
handle the full complement of Unix files and their properties.

ufsdump (or vxdump) should fit the bill better, if you use one of
those filesystems. the negative aspect compared to zip is that you
can't compress the data if you want random access.
--
Kjetil T.

0 new messages