Skip to content

Instantly share code, notes, and snippets.

@vitorcalvi
Created May 15, 2024 16:02
Show Gist options
  • Save vitorcalvi/2c22da9b91a2967fada33cd723875f62 to your computer and use it in GitHub Desktop.
Save vitorcalvi/2c22da9b91a2967fada33cd723875f62 to your computer and use it in GitHub Desktop.
List and remove all conda env
# 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