zipgrep.cmd 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*---------------------------------------------------------------------------
  2. zipgrep.cmd (ye olde REXX procedure for OS/2)
  3. Script to search members of a zipfile for a string or regular expression
  4. and print the names of any such members (and, optionally, the matching
  5. text). The search is case-insensitive by default.
  6. History:
  7. original Bourne shell version by Jean-loup Gailly
  8. modified by Greg Roelofs for Ultrix (no egrep -i) and zipinfo -1
  9. OS/2 REXX script by Greg Roelofs
  10. Last modified: 19 Jul 93
  11. ---------------------------------------------------------------------------*/
  12. PARSE ARG string zipfile members
  13. if (string == '') then do
  14. say 'usage: zipgrep search_string zipfile [members...]'
  15. say ' Displays the names of zipfile members containing a given string,'
  16. say ' in addition to the matching text. This procedure requires unzip'
  17. say ' and egrep in the current path, and it is quite slow....'
  18. exit 1
  19. end
  20. /* doesn't seem to work...
  21. newq = RXQUEUE("Create",zipgrep_pipe)
  22. oldq = RXQUEUE("Set",newq)
  23. */
  24. /* flush the queue before starting */
  25. do QUEUED()
  26. PULL junk
  27. end
  28. /* GRR: can also add "2>&1" before pipe in following external command */
  29. '@unzip -Z1' zipfile members '| rxqueue'
  30. do while QUEUED() > 0
  31. PARSE PULL file
  32. '@unzip -p' zipfile file '| egrep -is' string
  33. if rc == 0 then do
  34. SAY file':'
  35. /* can comment out following line if just want filenames */
  36. '@unzip -p' zipfile file '| egrep -i' string
  37. end
  38. end
  39. /*
  40. call RXQUEUE "Delete",newq
  41. call RXQUEUE "Set",oldq
  42. */
  43. exit 0