fstools : ax (archive extract)

The Problem

There are many common archive formats: .tar .tar.gz .tgz .tar.bz2 .zip .7z
with different commands for content listing and extracting:

All these extracting commands write to the current directory, creating a mess of files.
Even worse: tar overwrites existing files without warning!

The Solution

We need a generic and saver alternative for handling archives:
ax: extract or list archive
usage: ax [-v] [-l] ARCHIVE
options: -v  verbose mode
         -l  list (instead of extract)
archive types: .tar .tar.gz .tgz .tar.bz2 .zip .7z
Instead of 5 commands with a lot of different option you only have to remember one!

ax first scans the content of the archive and if there is no toplevel directory in it, ax adds the archive name as the toplevel directory for extracting.

ax also extracts extended file attributes (ACLs and file capabilities) from tar archives (if you have specific system rights, like UID=0).

Example (user input is bold):

framstag@moep:/tmp: ll test*
-rw-r--r-- framstag users    1,402,880 2016-09-06 14:17:01 test.tar
-rw-r--r-- framstag users    1,352,661 2016-09-06 14:17:18 test.zip

framstag@moep:/tmp: ax -lv test.tar
$ tar tvf /tmp/test.tar
-rw-r--r-- framstag/users 81198 2016-09-06 14:15 fritz.png
-rw-r--r-- framstag/users 82176 2016-09-06 14:15 munin.png
-rw-r--r-- framstag/users 26388 2016-09-06 14:15 phoon.png
-rw-r--r-- framstag/users 23833 2016-09-06 14:15 W7-crash.png
-rw-r--r-- framstag/users 40156 2016-09-06 14:15 watschel.png

framstag@moep:/tmp: ax test.tar
test/fritz.png
test/munin.png
test/phoon.png
test/W7-crash.png
test/watschel.png

framstag@moep:/tmp: ax -lv test.zip
$ unzip -l /tmp/test.zip
    81198  2016-09-06 14:15   fritz.png
    82176  2016-09-06 14:15   munin.png
    26388  2016-09-06 14:15   phoon.png
    23833  2016-09-06 14:15   W7-crash.png
    40156  2016-09-06 14:15   watschel.png

framstag@moep:/tmp: ax test.zip
Extraction directory test/ does already exist. 
Overwrite? yes
test/fritz.png
test/munin.png
test/phoon.png
test/W7-crash.png
test/watschel.png


Author: Ulli Horlacher