I think it's more safe and proper to actually iterate the files in the JAR files instead of scanning through their binary contents:
if unzip -l $jarfile | grep -q JndiLookup.class; then
Should also be faster than the current implementation because the unzip utility knows how to quickly find the class names within the ZIP file dictionary without having to scan/read the entire file.
https://github.com/cloudera/cloudera-scripts-for-log4j/blob/7e3765001256abc3328018421850ff86a1f336f2/hdp_support_scripts/delete_jndi.sh#L31
I think it's more safe and proper to actually iterate the files in the JAR files instead of scanning through their binary contents:
Should also be faster than the current implementation because the unzip utility knows how to quickly find the class names within the ZIP file dictionary without having to scan/read the entire file.