Skip to content

Instantly share code, notes, and snippets.

@derekmurawsky
Last active September 6, 2024 17:42
Show Gist options
  • Select an option

  • Save derekmurawsky/71e596588320521f5145a152858239ef to your computer and use it in GitHub Desktop.

Select an option

Save derekmurawsky/71e596588320521f5145a152858239ef to your computer and use it in GitHub Desktop.
A simple cleanup script that looks for common local dependency caches below your current directory and deletes them
#!/bin/bash
find . -name '.yarn' -type d -prune -exec rm -rf '{}' +
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
# Note: There may be things to consider with deleting the .terraform directory. For me, this works
# but think through it for you're use case. https://developer.hashicorp.com/terraform/cli/init#working-directory-contents
find . -name '.terraform' -type d -prune -exec rm -rf '{}' +
@derekmurawsky
Copy link
Author

derekmurawsky commented Sep 6, 2024

There has to be a cleaner way as this grows... At least this method only iterates through once. find . \( -name '.yarn' -o -name 'node_modules' -o -name '.terraform' -o -name 'cdk.out' -o -name 'target' -o -name '.venv' -o -name 'dist' -o -name 'out' -o -name '.next' \) -type d -prune -exec rm -rf '{}' +

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment