File: zipgrep.cmd

package info (click to toggle)
unzip 6.0-16%2Bdeb8u3
  • links: PTS
  • area: main
  • in suites: jessie
  • size: 8,768 kB
  • ctags: 10,194
  • sloc: ansic: 55,133; cpp: 4,084; makefile: 2,517; asm: 1,789; cs: 1,012; sh: 119
file content (56 lines) | stat: -rw-r--r-- 1,601 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*---------------------------------------------------------------------------

   zipgrep.cmd  (ye olde REXX procedure for OS/2)

   Script to search members of a zipfile for a string or regular expression
   and print the names of any such members (and, optionally, the matching
   text).  The search is case-insensitive by default.

   History:
     original Bourne shell version by Jean-loup Gailly
     modified by Greg Roelofs for Ultrix (no egrep -i) and zipinfo -1
     OS/2 REXX script by Greg Roelofs

   Last modified:  19 Jul 93

  ---------------------------------------------------------------------------*/

PARSE ARG string zipfile members

if (string == '') then do
    say 'usage:  zipgrep search_string zipfile [members...]'
    say '   Displays the names of zipfile members containing a given string,'
    say '   in addition to the matching text.  This procedure requires unzip'
    say '   and egrep in the current path, and it is quite slow....'
    exit 1
end

/* doesn't seem to work...
newq = RXQUEUE("Create",zipgrep_pipe)
oldq = RXQUEUE("Set",newq)
 */

/* flush the queue before starting */
do QUEUED()
    PULL junk
end

/* GRR:  can also add "2>&1" before pipe in following external command */
'@unzip -Z1' zipfile members '| rxqueue'

do while QUEUED() > 0
    PARSE PULL file
    '@unzip -p' zipfile file '| egrep -is' string
    if rc == 0 then do
        SAY file':'
        /* can comment out following line if just want filenames */
        '@unzip -p' zipfile file '| egrep -i' string
    end
end

/*
call RXQUEUE "Delete",newq
call RXQUEUE "Set",oldq
 */

exit 0