Skip to content

Instantly share code, notes, and snippets.

@whaley
Created July 11, 2011 17:27
Show Gist options
  • Save whaley/1076331 to your computer and use it in GitHub Desktop.
Save whaley/1076331 to your computer and use it in GitHub Desktop.
#!/bin/bash
rootDirectory="$1"
stringToMatch="$2"
for jarfile in $(find "$rootDirectory" -name '*.jar')
do
grepOut=$(jar tvf "$jarfile" | grep "$stringToMatch")
if [[ $grepOut ]]
then
echo "Matching file(s) found in $jarfile"
echo "$grepOut" | awk {'print "\t"$NF'}
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment