Skip to content

Instantly share code, notes, and snippets.

@jamieparfet
Created June 18, 2018 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamieparfet/d48c383c3b424664da2ccd2621e11c40 to your computer and use it in GitHub Desktop.
Save jamieparfet/d48c383c3b424664da2ccd2621e11c40 to your computer and use it in GitHub Desktop.
Extract all jar files within subdirectories into respective folders
#!/bin/bash
BASE_PATH=/root/source-code/project/subdir
REMOVE_FROM_PATH=/root/source-code/project/
OUTPUT_DIR=/root/testing/temp
for JAR_FILE in $(find "$BASE_PATH" -name "*.jar" -type f); do
# Show found .jar file
echo "File: $JAR_FILE"
# Perform unzip operation
unzip -qq $JAR_FILE -d $OUTPUT_DIR/$(echo ${JAR_FILE#$REMOVE_FROM_PATH} | sed 's/\//\__/g')
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment