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