Last active
June 6, 2023 17:56
-
-
Save SOSANA/fc76fd0c390aca9f3147d239088219d3 to your computer and use it in GitHub Desktop.
A bash script to remove all sub folders containing node_modules from the root directory
This file contains 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 | |
# run this command in root directory | |
# sh ./remove_node_modules.sh; | |
# Find all node_modules folders in the root directory | |
find . -type d -name "node_modules" | |
# Initialize the count of folders removed to 0 | |
count=0 | |
# Remove all node_modules folders | |
for node_modules in $(find . -type d -name "node_modules"); do | |
echo "Beginning removal of node_modules folder: $node_modules" | |
rm -rf $node_modules | |
echo "Node_modules folder $node_modules has been removed" | |
# Increment the count of folders removed by 1 | |
count=$((count + 1)) | |
done | |
# Print the count of folders removed to the console | |
echo "A total of $count node_modules folders have been removed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment