Created
October 22, 2024 09:54
-
-
Save NotYusta/ae940438026b8096873bddefa9ba3a57 to your computer and use it in GitHub Desktop.
Delete Jars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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