tar and stdio (was: Anyone know of a random data generator?)

bscott at ntisys.com bscott at ntisys.com
Thu Jul 29 21:22:01 EDT 2004


On Fri, 30 Jul 2004, at 5:21am, invalid at pizzashack.org wrote:
> Only as the argument to the 'f' flag...
> 
>   $ cat intro |tar cf plah.tar -
>   tar: -: Cannot stat: No such file or directory
>   tar: Error exit delayed from previous errors
> 
> The intended result in this case can be acheived by just leaving off
> the '-' at the end.  Then tar will read its input from stdin.

  Er, not with my 'tar', and I don't think in the general case, either.

$ cat .bashrc | tar cf foo.tar  
tar: Cowardly refusing to create an empty archive
Try `tar --help' for more information.
$ 

  The 'tar' program works with tar archives and filesystems, not arbitrary
data streams.  You can't just take the output of "cat" (or the contents of
any other file or program via a file descriptor) and put them in a tar
archive as an archive member.

  When it comes to working with a tar archive, you can use stdio because a
tar archive, like any other file in Unix, is just a data stream.  But the
filesystem side of tar needs to be the filesystem.

  If you just want to move a data stream on to or off of a device, just use
"dd" or "cat", or plain shell redirection.

-- 
Ben Scott <bscott at ntisys.com>
| The opinions expressed in this message are those of the author and do  |
| not represent the views or policy of any other person or organization. |
| All information is provided without warranty of any kind.              |





More information about the gnhlug-discuss mailing list