-2

We have to find a string, let's say "foobar" among several webapps.

However, some webapps contain zipped files, eg log4j.jar.

Therefore, grep -IR "foobar" /pathto/tomcatroot/ won't work, because of compressed files.

unzip -c /pathto/tomcatroot/libdir/log4j.jar |grep foobar can solve the problem, but only for one file

Is there a way to achieve this for a whole directory?

bgtvfr
  • 1,224
  • 10
  • 19

1 Answers1

1

For a jar file you can try this:

for i in *.jar; do jar -tvf "$i" | grep  yourstring && echo "$i"; done

For zip files you can try zcat or zgrep

zcat yourfile.zip |grep string
Daniel PC
  • 86
  • 4