Afficher un message
Vieux 21/08/2006, 15h03   #4
Chris Mattern
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to use unzip with pipe

Stephane Chazelas wrote:
> On 21 Aug 2006 02:07:22 -0700, Danish wrote:
> [...]
>
>>>Out of tens of postings, nobody gave a "correct" one:
>>>
>>> unzip "*.zip"

>
> [...]
>
> Indeed, there's a bug in unzip that makes it behave the msdos
> way even on Unix (where *, ?, [, \ are allowed in filenames).
>
> So the only correct one is
>
> unzip "*.zip"
>
> And if you want to use a for loop or find, you need to escape
> the *, ?, \ and [ characters first in filenames:
>
> Something like:
>
> for f in ./*.zip; do
> [ -f "$f" ] || continue
> [ -L "$f" ] && continue
> escaped_f=$(
> printf '%s\n' "$f" | sed 's/[][\?*]/\\&/g'
> )
> unzip "$escaped_f"
> done
>


Dear God, that's ugly. Whoever decided unzip shouldn't
handle a list of filenames but *should* try to do its own
globbing needs to be shot.


Chris Mattern
  Réponse avec citation
 
Page generated in 0,05025 seconds with 9 queries