Quitar nodemodules de las subcarpetas de un directorio y preguntar si esta seguro

PHOTO EMBED

Thu Jan 19 2023 19:16:50 GMT+0000 (Coordinated Universal Time)

Saved by @dap465

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
content_copyCOPY