Ax Archive Extract
From Noah.org
ax
This is a simple little shell script that I wrote to handle most archives that I run across. You don't have e to tell it what type of decompression to use. Simply run it with the archive name as an argument:
ax my_tarball.tar.gz ax my_tarball.tar.bz2 ax my_stuf.zip
Click here to download this script: ax
#!/bin/sh # This extracts the given archive. It detects gzip, bzip2, zip, tar, etc. # # TODO attempt to detect exploding tarballs (ones that don't create a # subdirectory and then spew files all over the current directory). # # tar tzf tarball.tar.gz | awk -F '/' '{print $1}' | uniq | wc -l # # A well behaved tarball should only create one directory or file in the # current directory. # # $Id: ax 170 2008-01-15 11:43:33Z root $ OPT='xf' FILE=$1 case "${FILE}" in *.zip) unzip -lv "${FILE}" ;; *.tgz) gunzip -c "${FILE}" | tar $OPT - ;; *.bz2) bunzip2 -c "${FILE}" | tar $OPT - ;; *.tar.gz) gunzip -c "${FILE}" | tar $OPT - ;; *.tar.bz2) bunzip2 -c "${FILE}" | tar $OPT - ;; *.tar.Z) uncompress -c "${FILE}" | tar $OPT - ;; *.rar) UNRAR=`which unrar` if $? then unrar-free -x "${FILE}" else unrar x "${FILE}" fi ;; *) tar $OPT ${FILE} ;; esac