#!/bin/sh # *********** unwrap # *********** a shell script to ease unpacking several sorts of archives # *********** version 1.5 by scott arrington VERSION=1.5 # you can choose between tar or cpio... # the -L option to unzip unzips with lowercase filenames! # 29 Dec 1998 # added a handler for uncompressed tar files. it uses tar, not cpio. # added a variable for version number, bumped version number. # it would be nice to have a "list" option, that would just show the # contents of the archive without opening it. # while we're on the wish list, rpm support might be helpful. # # 23 Feb 1999 # added -l for listing mode, which required rearranging things. # # 23 Mar 1999 # complains about an empty file list. maybe no args should attempt # to read from stdin instead? LISTONLY= function unpack () { case "$1" in *.tar.gz|*.tar.Z|*.tgz) #gzip -d < $1 | cpio -i -v -d -u -H ustar ;; gzip -d < $1 | tar -xvf - ;; *.tar.bz2|*.tbz) #bzip2 -d < $1 | cpio -i -v -d -u -H ustar ;; bzip2 -d < $1 | tar -xvf - ;; *.tar) #cpio -i -v -d -u -H ustar $1 ;; tar -xvf $1 ;; *.gz) gunzip -d $1 ;; *.zip) unzip -L $1 ;; *) # default echo wrong file type for $1 ; echo " --- check for a '_' where there should be a '.'"; echo " --- try 'unwrap --help' for help";; esac } function listcontents () { case "$1" in *.tar.gz|*.tar.Z|*.tgz) gzip -d < $1 | tar -tvf - ;; *.tar.bz2|*.tbz) bzip2 -d < $1 | tar -tvf - ;; *.tar) tar -tvf $1 ;; *.gz) gunzip -tvf $1 ;; *.zip) unzip -L -l $1 ;; *) echo unrecognized file type for $1 ;; esac } ############################################################################# # the buck starts here if [ $# = 0 ]; then echo "usage: unwrap filename"; exit fi case "$1" in -h|--help) echo "unwrap $VERSION by scott arrington"; echo "unpack archives"; echo "usage: unwrap filename"; echo " supported archive types:"; echo " tar archives: *.tar"; echo " gzipped tar archives: *.tar.gz, *.tgz"; echo " compressed tar archives: *.tar.Z"; echo " bzipped tar archives: *.tar.bz2, *.tbz"; echo " zip archives: *.zip" echo " gzip archives: *.gz" ;; -l|--list) LISTONLY=true; shift; ;; esac while ! [ -z "$1" ]; do if [ "$LISTONLY" = "true" ]; then listcontents "$1" else unpack "$1" fi shift done # the buck stops here #############################################################################