How to archive several files with tar?

Geoff Clare gwc at root.co.uk
Wed Jun 12 22:58:17 AEST 1991


In <16873 at darkstar.ucsc.edu> jik at cats.ucsc.edu (Jonathan I. Kamens) writes:

>In article <ADRIANHO.91Jun9105223 at barkley.berkeley.edu>, adrianho at barkley.berkeley.edu (Adrian J Ho) writes:
>|> The idea is _not_ to put the tar file in the directory you're tar'ing,
>|> because your tar file will otherwise end up being included in itself.
>|> In the worst case, it could be the _last_ file included, which means
>|> that your tar file could end up being _twice_ as large as it's
>|> supposed to be.

>  Actually, the worst case is that the tar file will continue to grow as tar
>writes into it, so that when tar opens that file to archive it, the file will
>grow as tar is archiving it, which means that there will be more to archive,
>etc., etc. until the disk fills up or the user exceeds his quota or the
>maximum file size or whatever.

Actually, Jonathan is wrong and Adrian was right.

Although many utilities will fill the disk if made to read their output
file, this is not true of tar (unless you have a broken tar).  In the tar
output format the size of each file is contained in a header which
precedes the file's contents.  Hence the amount of data which tar will
read from its own output file is limited to its size when tar starts
reading it.  If the output file is the last input file, it will
approximately double in size when tar reads it.

Any decent version of tar will warn you if an input file changes in size.
-- 
Geoff Clare <gwc at root.co.uk>  (Dumb American mailers: ...!uunet!root.co.uk!gwc)
UniSoft Limited, London, England.   Tel: +44 71 729 3773   Fax: +44 71 729 3273



More information about the Comp.unix.questions mailing list