Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.76 KB | None | 0 0
  1. ###############################################################################
  2. #   Search for JARs containing the given classname
  3. #   Global:
  4. #       None
  5. #   Arguments:
  6. #       $1 = classname
  7. #       $+ = paths where to look for JARs (recursively)
  8. #   Returns:
  9. #       Paths to JARs that contain the given class
  10. ###############################################################################
  11. find_jar() {
  12.     if [[ $# -lt 2 ]]; then
  13.         echo 'Usage: find_jar CLASSNAME PATH-1 [PATH-2 ... PATH-n]'
  14.         return
  15.     fi
  16.  
  17.     class=$1
  18.     shift
  19.     IFS=$(echo -en '\n\b')
  20.     for file in $(find -L $@ -type f -iname '*.jar'); do
  21.         if unzip -l "$file" | grep $class &>/dev/null; then
  22.             echo "$file"
  23.         fi
  24.     done
  25.     unset IFS
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement