Created
May 5, 2020 19:16
-
-
Save sukima/c7d56a6e42f3b78ca8957bc31ae02100 to your computer and use it in GitHub Desktop.
Forcfully remove old node_modules recursivly
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 | |
DIR="${1##/}" | |
DIR="${DIR-:.}" | |
entries=$(mktemp) | |
trap 'rm -f "$entries"' EXIT | |
find "${DIR}" -name node_modules -prune -atime +30d > "$entries" | |
if [[ ! -s "$entries" ]]; then | |
exit 0 | |
fi | |
echo "About to DESTROY the following directories:" | |
cat "$entries" | |
echo | |
read -n 1 -p "Are you sure? [y/N]" confirmation | |
if [[ $confirmation != "y" && $confirmation != "Y" ]]; then | |
exit 0 | |
fi | |
while read entry; do | |
nice rm -rf "$entry" & | |
done < "$entries" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment