zipgrep

来自「压缩解压,是unzip540的升级,这个外国网站摘来的源码,是evb编写.」· 代码 · 共 59 行

TXT
59
字号
#! /bin/sh# zipgrep: searches the given zip members for a string or pattern# This shell script assumes that you have installed UnZip.pat=""opt=""while test $# -ne 0; do  case "$1" in  -e | -f) opt="$opt $1"; shift; pat="$1";;  -*)      opt="$opt $1";;   *)      if test -z "$pat"; then             pat="$1"           else             break;           fi;;  esac  shiftdoneif test $# = 0; then  echo "usage: `basename $0` [egrep_options] pattern zipfile [members...]"  echo searches the given zip members for a string or pattern  exit 1fizipfile="$1"; shiftlist=0silent=0opt=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'`case "$opt" in  *l*) list=1; opt=`echo $opt | sed s/l//`esaccase "$opt" in  *h*) silent=1esacif test -n "$opt"; then  opt="-$opt"fires=0IFS=''for i in `unzip -Z1 "$zipfile" ${1+"$@"}`; do  if test $list -eq 1; then    unzip -p-L "$zipfile" "$i" | egrep $opt "$pat" > /dev/null && echo $i    r=$?  elif test $silent -eq 1; then    unzip -p-L "$zipfile" "$i" | egrep $opt "$pat"    r=$?  else    unzip -p-L "$zipfile" "$i" | egrep $opt "$pat" | sed "s|^|${i}:|"    r=$?  fi  test "$r" -ne 0 && res="$r"doneexit $res

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?