Listing 3 unpack
#!/bin/sh
# Listing 3:
# Fri Jan 5 14:57:59 EST 2001
# /usr/local/bin/unpack
# Copyright 2001, 2002, 2003, Chris F.A. Johnson
# Released under the terms of the GNU General Public License
for file; do
case $file in
*.zip|*.ZIP)
unzip "$file"
;;
*.tar)
tar xvpf "$file"
;;
## .tgz and .tar.tgz are equivalent: tar & gzip;
## .Z (UNIX compress format) can also be uncompressed by gunzip
*.tgz|*.tar.gz|*.tar.Z)
gunzip -c "$file" | tar xvp
;;
## tar & bzip2
*.tar.bz2|*.tbz2)
bunzip2 -c "$file" | tar xvp
;;
## gzipped and bzip2ed files are uncompressed to the current
## directory, leaving the original files in place
*.gz)
gunzip -c "$file" > "`basename "$file" .gz`"
;;
## compress
*.Z)
gzip -c "$file" > "`basename "$file" .Z`"
;;
## bzip2
*.bz2)
bunzip2 -c "$file" > "`basename "$file" .bz2`"
;;
esac
done
|