Re: A silly question about tar
On Sat, 2007-03-17 at 14:34 +0100, Joe Hart wrote:
> Cameron Hutchison wrote:
> [snip]
>
> >
> > 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
> > }
> >
> >
>
> Another handy little script. I just love this list. It's a lot easier
> to type x *.zip or x *.rar than it is to right-click on a file and say
> "extract here" over and over, or selecting a bunch of files and have 20
> instances of ark start all at once.
>
> Thanks. I made one little adaptation so that it says it's doing
> something. I tried it on a directory full of zip files and it
> uncompressed them so quickly that I thought it didn't work. Of course
> it did.
Don't forget to install "unp" it does all the case stuff auto-magically.
But you should also look at installing things like "orange" and other
archive extraction tools.
--
greg, greg@gregfolkert.net
Novell's Directory Services is a competitive product to Microsoft's
Active Directory in much the same way that the Saturn V is a competitive
product to those dinky little model rockets that kids light off down at
the playfield. -- Thane Walkup
Reply to: