Re: A silly question about tar
Adam Porter wrote:
>Thanks for your replies, everyone. It seems to me that there might be a
>market for a simple script frontend to tar that would handle shell-expanded
>wildcards; perhaps it could be included in Debian's package of tar. Would
>that be a good idea? Does anything like that already exist?
I have the following shell function defined in my .bashrc which I use to
extract the various archives I come across. It handles multiple archives
on the command line. Usage is simple:
$ x *.tar.gz
x ()
{
for archive in "$@"; do
case "$archive" in
*.tar* | *.t?z)
case $archive in
*.gz | *tgz | *.Z)
TARFLAGS="--use-compress-prog gzip"
;;
*.bz | *.bz2 | *tbz)
TARFLAGS="--use-compress-prog bzip2"
;;
*)
TARFLAGS=""
;;
esac;
tar xf "$archive" ${TARFLAGS}
;;
*.zip | *.ZIP)
unzip -q "$archive"
;;
*.deb)
dpkg-deb -x "$archive" .
;;
*.rar)
unrar x "$archive"
;;
*.cpio)
cpio --extract --make-directories --file="$archive"
;;
*.cpio.gz)
gzip -dc "$archive" | cpio --extract --make-directories
;;
*)
echo "Unknown archive format" 1>&2
;;
esac;
done
}
Reply to: