BASH   67

jardigger bash

Guest on 21st April 2022 01:34:34 AM

  1. #!/bin/bash
  2.  
  3. if [ "$#" -eq 0 ]
  4. then
  5.     echo
  6.     echo "Search recursevily through directory containing JAR files for filenames inside JARs"
  7.     echo "Usage: $0 <filename_or_path_or_part_of_it> [<directory_path_to_search>]"
  8.     echo "Example: $0 com/sun/xml/ws/spi/ProviderImpl /opt/oracle/app/Middleware/"
  9.     echo
  10.     exit
  11. fi
  12.  
  13. searchdir="/opt/oracle/app/Middleware/wlserver_10.3/server/lib/"
  14. if [ "$#" -eq 2 ]
  15. then
  16.     searchdir=$2
  17. fi
  18.  
  19. mismatched=0
  20. echo
  21. echo "Searching filename $1 from $searchdir :"
  22. echo
  23.  
  24. for i in `find $searchdir -type f -name '*.jar'`;
  25. do
  26.     res=`jar tf $i 2>/dev/null | grep $1`
  27.     if [[ $res != "" ]]
  28.     then
  29.       echo -en "\r_____________________________________________________________________"
  30.       echo
  31.       echo $i
  32.       echo
  33.       echo "$res"
  34.       echo
  35.     else
  36.         mismatched=$[$mismatched+1]
  37.         echo -en "\rMismatched JARs: $mismatched"
  38.     fi
  39. done  
  40.  
  41. echo

Raw Paste


Login or Register to edit or fork this paste. It's free.