[nycbug-talk] tar question

Bob Ippolito bob
Sat Jun 19 19:48:40 EDT 2004


On Jun 19, 2004, at 8:34 PM, Pete Wright wrote:

> Okan Demirmen wrote:
>
>> On Sat 2004.06.19 at 18:39 -0500, Pete Wright wrote:
>>
>>> I have a wierd question about "tar".  how is the order of what it 
>>> put into the archive dictated?  I assumed it was alphabetic, but 
>>> I've been putting a file to tape and is not in alpha order.  It's 
>>> not like it matters really but I was woundering if anyone has some 
>>> insight to this.  the man page does not shed any light into this.
>>
>> should be order of addition to archive file.
>
> understood, but I just tar'd a dir with about 300-400 dirs/files in 
> it.  so if i tar ala:
>
> tar cvf /dev/nsa0 /path/to/foo/
>
> I noticed that the things were not in alpha order.  I double checked 
> the output and it didn't look like any pattern, unless it was by size 
> maybe, but i don't think that was the case either.  i also would have 
> thought that it would be in the same pattern as when you do a "ls" 
> (i.e. letters/case/alpha etc).  that wasn't the case either...wierd

It's not really weird.  In order to have any sorting you would need to 
gather the list of every file that goes in the tar first and sort it.  
Since tar is meant for tape, it doesn't have a TOC at the beginning 
(like zip does), so it has no reason to know every single file it's 
going to archive beforehand.  As I said before, it's HIGHLY likely that 
it goes in the same order as you pass via args and otherwise arbitrary 
filesystem order.  On top of that, the man page also doesn't specify 
how it traverses directories, which could happen in several different 
ways depending on the implementation.

-bob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
Url : http://lists.nycbug.org/pipermail/talk/attachments/20040619/d4635658/attachment.bin 



More information about the talk mailing list