Skip to content

Instantly share code, notes, and snippets.

@garretttaco
Created April 19, 2017 22:55
Show Gist options
  • Save garretttaco/04fef6b1d8cbfb1c3d2cc8ea41613573 to your computer and use it in GitHub Desktop.
Save garretttaco/04fef6b1d8cbfb1c3d2cc8ea41613573 to your computer and use it in GitHub Desktop.
Delete node_modules that have not been touched after 60 days.
#!/bin/bash
delete_nm() {
find $1 -type d -maxdepth 1 -mtime +60 | xargs -I $ find $ -type d -name node_modules -maxdepth 1 -exec echo rm -rf {} \;
read -p "Are you sure you wish to delete the node_modules folders above? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
find ~/Projects -type d -maxdepth 1 -mtime +60 | xargs -I $ find $ -type d -name node_modules -maxdepth 1 -exec rm -rf {} \;
echo "Finished delete"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment