[comp.unix.xenix] Using tar with the 'r' option

frankb@usource.UUCP (Frank Bicknell) (05/27/89)

I have used the 'r' option for tar to append additional archives
on floppy devices.  For example,

tar rn0 *

tacks the files from the current directory on the end of
whatever is defined as tar device 0.  BTW... the n option tells tar that
it can seek on that device (unlike a tape which cannot be seek'ed).

On other (non-SCO) xenix and unix systems, I have also been able
to tack things on the end of file archives.  For example:

tar rnf tar.image *

does the same as above, except the output device is the file
tar.image.  I can't seem to get SCO tar to do this right.  It
cuts into the tail end of the existing tar image in the file and
begins appending too soon.

The manual does indicate that one is not able to append to tapes:
that's reasonable since tar doesn't know it's read that last
trailer block of nulls until it has already passed the head.
There's no way short of rewinding and counting blocks to
overwrite that trailer.  (I guess ntar will record the length of
the archive in the first record or something to allow this to be
done in the future... maybe).

Anyway, it is certainly possible to keep track of and seek back
to that trailer record when appending to a file.  Why is it not
done?
-- 
Frank Bicknell
UniSource; 1405 Main St, Ste 709; Sarasota, FL 34236
killer!usource!frankb || frankb@usource.UUCP

chip@ateng.ateng.com (Chip Salzenberg) (06/05/89)

According to frankb@usource.UUCP (Frank Bicknell):
>I have used the 'r' option for tar to append additional archives
>on floppy devices.  [...]
>On other (non-SCO) xenix and unix systems, I have also been able
>to tack things on the end of file archives.  [...]
>I can't seem to get SCO tar to do this right.

I got it to work by specifying a blocksize of one:

	tar rvfb archive.tar 1 addfile1 addfile2

Of course, it *is* slow, but it works...
-- 
Chip Salzenberg             <chip@ateng.com> or <uunet!ateng!chip>
A T Engineering             Me?  Speak for my company?  Surely you jest!
	  "It's no good.  They're tapping the lines."

pjh@mccc.UUCP (Pete Holsberg) (06/08/89)

Is there anyway to get tar to extract a file from an archive file and send it
to stdout (rather than to a file)?
-- 
Pete Holsberg, Professor, Technology Division
Mercer County Community College, Box B, Trenton, NJ 08690  
{backbone}!rutgers!princeton!mccc!pjh

mhlevy@sbee.sunysb.edu (Mark Levy) (06/12/89)

In article <771@mccc.UUCP>, pjh@mccc.UUCP (Pete Holsberg) writes:
> Is there anyway to get tar to extract a file from an archive file and send it
> to stdout (rather than to a file)?
> -- 
> Pete Holsberg, Professor, Technology Division


Try:
     tar xvf -   ( the '-' means stdout or stdin )

Mark
-- 
~~~~~~~~~  Disclaimer???   We don't need no stinkin' disclaimer!!!  ~~~~~~
Mark Levy { mhlevy@sbccvm.BITNET   } 	% Debbie Gibson is pregnant,  with
          { mhlevy@sbee.sunysb.edu }    %   my two headed love child....
          { mhlevy@ccvm.sunysb.edu } 	%                         Mojo Nixon

iv@hal6000.UUCP (06/13/89)

/* Written  6:25 pm  Jun 11, 1989 by sbee.UUCP!mhlevy in comp.unix.xenix */
|* ---------- "Re: Using tar with the 'r' option" ---------- */
| In article <771@mccc.UUCP>, pjh@mccc.UUCP (Pete Holsberg) writes:
| > Is there anyway to get tar to extract a file from an archive file and send
| > it to stdout (rather than to a file)?
| > -- 
| > Pete Holsberg, Professor, Technology Division
| 
| 
| Try:
|      tar xvf -   ( the '-' means stdout or stdin )
| 
| Mark
\* End of text from hal6000:comp.unix.xenix */

No, no, no.  "tar xf -" means to read the ARCHIVE from stdin, not to
write the file to stdout.  The `f' key in all cases means the ARCHIVE file.
----
IV  (aka John Elliott IV)	 Domain: iv@hal6000.Tandy.COM
Tandy Systems Software		   UUCP: ...!texbell!letni!hal6000!iv
900 Two Tandy Center		     or: ...!decvax!microsoft!trsvax!hal6000!iv
Fort Worth, TX 76102		  Phone: 817/390-2701; 9:30am-6:00pm CST, M-F

jmm@eci386.uucp (John Macdonald) (06/15/89)

In article <771@mccc.UUCP>, pjh@mccc.UUCP (Pete Holsberg) writes:
> Is there anyway to get tar to extract a file from an archive file and send it
> to stdout (rather than to a file)?

In article <1188@sbee.sunysb.edu> mhlevy@sbee.sunysb.edu (Mark Levy) writes:
>
>Try:
>     tar xvf -   ( the '-' means stdout or stdin )

Sorry Mark, you misread the question - he wanted the extracted file to go
to stdout, you are giving syntax for reading the archive from stdin.

Pete, there is no way to do what you want with the tar's I'm familiar with.
Nor is it possible using pax - the new PD Posix-compliant replacement for
both tar and cpio - although, using its renaming capabilities, you can avoid
overwriting a file of the same name or having the file be placed into some
absolute pathname (so you could do it with a script that extracts the file
into /tmp, copies it out to stdout, and deletes it, if that is acceptable).