|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
[A complimentary Cc of this posting was sent to
Danish <me.linuxadmin@gmail.com>], who wrote in article <1155537414.080719.126630@m79g2000cwm.googlegroups .com>: > Hi, > Can anyone please guide me as to how use pipe with unzip. For eg, Iv > got a lot of zip files in a directory. So id like to `ls` them to a > pipe and then unzip it. > > $ls *.zip > > 1.zip > 2.zip > > Can I do > $ls *.zip | unzip > > I tried it, but was not working...Tried googling but didnt find > much..Need it urgently Out of tens of postings, nobody gave a "correct" one: unzip "*.zip" Hope this s, Ilya |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
Ilya Zakharevich wrote: > [A complimentary Cc of this posting was sent to > Danish > <me.linuxadmin@gmail.com>], who wrote in article <1155537414.080719.126630@m79g2000cwm.googlegroups .com>: > > Hi, > > Can anyone please guide me as to how use pipe with unzip. For eg, Iv > > got a lot of zip files in a directory. So id like to `ls` them to a > > pipe and then unzip it. > > > > $ls *.zip > > > > 1.zip > > 2.zip > > > > Can I do > > $ls *.zip | unzip > > > > I tried it, but was not working...Tried googling but didnt find > > much..Need it urgently > > Out of tens of postings, nobody gave a "correct" one: > > unzip "*.zip" > > Hope this s, > Ilya Thank you very much Danish |
|
|
|
#3 (permalink) |
|
Messages: n/a
Hébergeur: |
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 -- Stephane |
|
|
|
#4 (permalink) |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#5 (permalink) |
|
Messages: n/a
Hébergeur: |
[A complimentary Cc of this posting was sent to
Chris Mattern <syscjm@gwu.edu>], who wrote in article <12ejf8nmrj4o0e7@corp.supernews.com>: > >>>Out of tens of postings, nobody gave a "correct" one: > >>> unzip "*.zip" > 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. Opionions differ. IMO, whoever got this (broken) idea that it is the shell who globs (and not CRTL of the called application) should be treated unmercifully. Only the arguments which are meaningful to be globbed should be globbed, and only the application knows its syntax to support this. Otherwise you get this "just do not have a file named `-rf'" logic. Of course, this flaw can't be easily fixed in current Unix shells (well, interaction with `complete' database can somewhat here). But whoever (?) wants to design a better shell (on a system with not-yet finished CRTL ;-), could revisit this problem. But I already expressed this opinion many times... Hope this s, Ilya |
|
|
|
#6 (permalink) |
|
Messages: n/a
Hébergeur: |
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> Opionions differ. IMO, whoever got this (broken) idea that it is the > shell who globs (and not CRTL of the called application) should be > treated unmercifully. Why should the wheel be reinvented for each and every application what can be done in a consistent manner by a single instance (the shell)? -- Daniel |
|
|
|
#7 (permalink) |
|
Messages: n/a
Hébergeur: |
[A complimentary Cc of this posting was sent to
Daniel Rock <v200638@deadcafe.de>], who wrote in article <eeofqi$26a7$2@server.rock.net>: > Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote: > > Opionions differ. IMO, whoever got this (broken) idea that it is the > > shell who globs (and not CRTL of the called application) should be > > treated unmercifully. > > Why should the wheel be reinvented for each and every application Not in applications; as I said, the default, "legacy-compatible", globbing would be done in CRTL. The applications should be able to override this. > what can be done in a consistent manner by a single instance (the > shell)? By definition, shell can't do any reasonable globbing; otherwise you get the "just do not have a file named -rf" syndrom. Only the application knows which arguments can have a meaning of a file-pattern, so may be globbed. Hope this s, Ilya |
|
|
|
#8 (permalink) |
|
Messages: n/a
Hébergeur: |
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> Only the application knows which arguments can have a meaning of a > file-pattern, so may be globbed. .... and that in a wonderful inconsistent way: C:\> cd Prog* C:\Programme> Note: Globbing is technically wrong here since "cd" only expects a single directory name as an argument. [In a directory with lots of .TXT-Files] C> notepad *.txt [a dialog pops up The syntax for file name, directory name or volume name is wrong (manually translated)] Note: Globbing makes sense here because I might want to edit multiple files at the same time. It's better let this shell doing this. And your famous "-rf" filename: -- is your fried. A much better work-around than begging for each application programmer implementing globbing consistent. > Hope this s, Hope this s, -- Daniel |
|
![]() |
| Outils de la discussion | |
|
|