[H-GEN] ksh scripting problem

Greg Black gjb at gbch.net
Sun Aug 24 02:33:59 EDT 2003


On 2003-08-24, Anthony Towns wrote:
> On Sun, Aug 24, 2003 at 12:57:26PM +1000, Greg Black wrote:
> > If you really want to do what you appear to be attempting here,
> > why are you not using the standard utility that god provided for
> > this task: pax?  
> 
> Wow. People actually use pax?

I used to say that, especially when I first read the man page
and saw that it had added yet another giant set of apparently
gratuitous differences from the already-learned syntax of tar
and cpio (neither of which get any prizes for intuitive usage).

But I had to learn how to drive pax at some point when I was
working on a system which implemented tar and cpio as wrappers
to pax -- and neither the tar nor the cpio interface worked as
it should for some task I needed to perform.  Although I dislike
the pax commands, it turns out that they're the sort of thing
you can learn (just like you learn dd) and in fact pax gives you
excellent tools for copying hierarchies of stuff around.  These
days, I use it all the time; and I recommend it.

I admit that I still use tar to create archives for software
distribution, because the tar syntax for that is burned into my
fingers.  However, this can be done just as well with pax (and
the resultant archive can be handled by any decent tar).  The
following incantations produce essentially identical results:

    tar czf foo.tgz foo
    pax -wzf foo.tgz foo

Both tar and pax can successfully dismantle foo.tgz made by
either method.  Where pax excels is in better handling of this
idiom:

    tar cf - foo | ( cd newdir ; tar xf - )

The paxism for that is:

    pax -rw foo newdir

All the examples could be extended by a selected set of other
pax or tar options for special purposes; these are the basics,
for those who might not yet know pax.

Cheers, Greg

-- 
Greg Black <gjb at gbch.net> <http://www.gbch.net/gjb.html>
GPG signed mail preferred; further information in headers.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 249 bytes
Desc: not available
URL: <http://lists.humbug.org.au/pipermail/general/attachments/20030824/cd27e6c2/attachment.sig>


More information about the General mailing list