Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "unarchive" script/function?
- X-seq: zsh-users 13671
- From: Christian Schneider <strcat@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: "unarchive" script/function?
- Date: Thu, 8 Jan 2009 15:06:05 +0100
- In-reply-to: <20090108015216.GW14649@xxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: Born to frag.
- References: <d2ecb10b0901070818v44d2bbbdvb03b11d0fb0410e0@xxxxxxxxxxxxxx> <20090108015216.GW14649@xxxxxxxxxxxxxxxxxxx>
* Vincent Lefevre <vincent@xxxxxxxxxx> typed:
> On 2009-01-07 11:18:38 -0500, TjL wrote:
> > Basically I want to be able to throw any kind of archive/compression
> > method and have them all dealt with, so I could theoretically do this:
> >
> > unarchive file1.zip file2.tar file3.tbz file4.tar.gz
> >
> > and the "unarchive' program would know what to do with each.
>
> FYI, I have in my .zshrc:
>
> unarch()
> {
> local file decomp
> for file in $@
> do
> unset decomp
> [[ ( $file:e == gz && $file:r:e == tar ) || $file:e == tgz ]] \
> && decomp=gunzip
> [[ $file:e == bz2 && $file:r:e == tar ]] \
> && decomp=bunzip2
> [[ $file:e == lzma && $file:r:e == tar ]] \
> && decomp=unlzma
> if [[ -z $decomp ]] then
> echo "Usage: $0 [ \033[4mtgz-file\033[m | \033[4mbz2-file\033[m ] | \033[4mlzma-file\033[m ] ..." >&2
> return 1
> fi
> if [[ -r $file ]] then
> echo "$0 $file ..."
> $decomp $file -c | tar xf -
> else
> echo "$0: $file is not readable" >&2
> fi
> done
> }
I use Çnp(1) (<http://packages.debian.org/etch/unp>); it's a perl script
which runs the correct unpack program depending on the file extension of
the given parameter. HTH
--
"Another world, another day, another dawn. "
Messages sorted by:
Reverse Date,
Date,
Thread,
Author