root_dir='/mnt/c/path/to/root/dir'
read -p "Do you want to proceed with 'yes to all'? (y/n) " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
proceed="y"
else
proceed="n"
fi
for i in {0..5}
do
for dir in $(find $root_dir -maxdepth $i -name "node_modules" -type d)
do
echo "The following directory will be deleted:" $dir
if [ $proceed = "n" ];
then
read -p "Do you want to proceed? (y/n) " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
rm -rf $dir
fi
else
rm -rf $dir
fi
done
done
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter