while [[ `brew list | wc -l` -ne 0 ]]; do for EACH in `brew list`; do brew uninstall --force --ignore-dependencies $EACH done done
Here is what the above code is Doing:
1. It’s creating a while loop that will run until the number of brew packages installed is 0.
2. It’s creating a for loop that will run for each package installed.
3. It’s uninstalling each package with the –force and –ignore-dependencies flags.