Skip to content

Instantly share code, notes, and snippets.

@tommymarshall
Last active August 29, 2015 14:07
Show Gist options
  • Save tommymarshall/4fccb61ded8bd1f53264 to your computer and use it in GitHub Desktop.
Save tommymarshall/4fccb61ded8bd1f53264 to your computer and use it in GitHub Desktop.
Deletes all node_module folders in folders that are older than 120 days.
#!/bin/bash
# Sensible defaults
# So clean
clear
echo "Deleting all old node_modules folders..."
# Process things
find ${1:-'~/Sites'} -type d -mtime +120 -maxdepth 1 | while read line; do
echo "Processing '$line'..."
if [ -d "$line/node_modules" ]; then
find "$line" -depth -name "node_modules" -type d | while read line; do
echo "Found! Deleteing: '$line'"
rm -rf $line
done
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment