Created
May 15, 2024 16:02
-
-
Save vitorcalvi/2c22da9b91a2967fada33cd723875f62 to your computer and use it in GitHub Desktop.
List and remove all conda env
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
# List all Conda environments | |
conda env list | |
# Capture the list of environment names and loop through them | |
while IFS= read -r line; do | |
# Extract the environment name from each line | |
name=$(echo "$line" | cut -d ' ' -f 1) | |
# Skip the first line (header) and the base environment | |
if [ "$name" != "#" ] && [ "$name" != "base" ]; then | |
# Remove the environment | |
echo "Removing environment: $name" | |
conda env remove --name "$name" --yes | |
fi | |
done < <(conda env list) | |
echo "All environments removed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment