Skip to content

Instantly share code, notes, and snippets.

@NotYusta
Created October 22, 2024 09:54
Show Gist options
  • Save NotYusta/ae940438026b8096873bddefa9ba3a57 to your computer and use it in GitHub Desktop.
Save NotYusta/ae940438026b8096873bddefa9ba3a57 to your computer and use it in GitHub Desktop.
Delete Jars
#!/bin/bash
# Check if the user provided a path argument
if [ -z "$1" ]; then
echo "Usage: $0 <path>"
exit 1
fi
# Set the PATH variable to the user-provided argument
SEARCH_PATH=$1
echo "Searching for .jar files in $SEARCH_PATH..."
# Search for all .jar files recursively in directories and delete them
find "$SEARCH_PATH" -type f -name "*.jar" -exec rm -f {} \;
echo "All .jar files deleted."
# Optionally, check again if any .jar files still exist within any directories
echo "Checking nested directories for remaining .jar files..."
find "$SEARCH_PATH" -type d | while read dir; do
if find "$dir" -type f -name "*.jar" | grep -q .; then
echo "Found .jar files in $dir"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment