[kwlug-disc] tar replacement

Khalid Baheyeldin kb at 2bits.com
Sat Dec 28 21:18:36 EST 2019


On Sat, Dec 28, 2019 at 3:07 PM Paul Nijjar wrote:

> I am sick and tired of tar. Using it for anything nontrivial is a
> nightmare, because its user interface is so bad and so finicky.
> (Example: --exclude='some/path' fails, but --exclude=some/path works.
> Meanwhile, --exclude=some/path/ also fails. But it always fails if it
> is in the wrong spot of the command, just because there is a secret
> ordering you have to remember. UGH.)
>

I used to be confused with these exclude options, until I realized that
it takes a glob pattern, i.e. a shell like wildcard. Also, it needs the
exclude
parameter to be before the -f one.

In other words:

If you say:

cd mydir
tar -czv --exclude="otherdir/*" -f archive.tgz .

It will exclude mydir/otherdir/* but include an empty directory entry for it
in the archive.

But if your current directory is different, then you do it like this

cd ~
tar -czv --exclude="*mydir*/otherdir/*" -f archive.tgz *mydir*

And once it works and you script it, you will forget about it, and it
should
always work from the script

Unfortunately tar is ubiquitous, so I am not getting rid of it anytime
> soon. But is there something else that is good and has a sane
> commandline interface?
>
> - Creates archives
> - Allows flexible inclusions and exclusions
> - Probably compresses files, although I don't mind piping to gzip or
>   bzip2 or xz
> - Easily available in Linux systems (ie packaged for Debian/Ubuntu)
> - Friendly to being used in scripts (even shell scripts, which are
>   their own abomination).
>

As you say tar is ubiquitous.

And as Jason said, cpio is a better archive tool. In fact, I used it a
decade
exclusively and it worked well, once you get over the fact that it takes a
list of file from stdin, unlike a command line argument like tar does.
Again, once you script it, it will all work.

That was in the UNIX world.

Once GNU and open source matured, and Linux came along, tar was the
only archive format used. One advantage is that tar is portable. Cpio was
not always portable, and there are a myriad of option. Upgrading from
Motorola System V UNIX to Intel SVR4 required a few options. I think it
had to do with endianess. Tar does not have these limitations, but since
you will be always using Intel/AMD machines, and Linux, cpio should be
portable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20191228/c31a70e0/attachment.htm>


More information about the kwlug-disc mailing list