Search code examples
unixwarear

Searching inside an EAR/WAR file for a jar by jar name


I'm trying to find which command I can use in order to search for a known jar file name, in a specific unknown .ear file (of many) in a specific directory.

Thanks !


Solution

  • To search for a jar in a single ear file you can try:

    unzip -l some_file.ear | grep -i known_file.jar
    

    If you want to search through more than one ear file, you can feed them one by one to the same command:

    for file in specific/directory/*.ear; do echo "$file: "; unzip -l $file | grep -i known_file.jar; done
    

    Which will list all the ear files and any potential matches within them.