2 # zipgrep: searches the given zip members for a string or pattern
3 # This shell script assumes that you have installed UnZip.
7 while test $# -ne 0; do
9 -e |
-f) opt
="$opt $1"; shift; pat
="$1";;
11 *) if test -z "$pat"; then
21 echo "usage: `basename $0` [egrep_options] pattern zipfile [members...]"
22 echo searches the given
zip members
for a string or pattern
29 opt
=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'`
31 *l
*) list
=1; opt
=`echo $opt | sed s/l//`
36 if test -n "$opt"; then
41 for i
in `unzip -Z1 "$zipfile" ${1+"$@"}`; do
42 if test $list -eq 1; then
44 unzip -p-L "$zipfile" "$i" |
egrep $opt "$pat" > /dev
/null
&& echo $i
46 elif test $silent -eq 1; then
48 unzip -p-L "$zipfile" "$i" |
egrep $opt "$pat"
51 unzip -p-L "$zipfile" "$i" |
egrep $opt "$pat" |
sed "s|^|${i}:|"
54 test "$r" -ne 0 && res
="$r"