#! /usr/bin/env bash set -e get_catalogs() { midclt call catalog.query | jq -r '.[] | .label' | grep -v 'OFFICIAL' } delete_catalog() { local CATALOG="${1}" printf 'Deleting catalog: %s... ' "$CATALOG" midclt call catalog.delete "$CATALOG" printf '\n' } get_catalogs | while read catalog; do [[ -n "$catalog" ]] || continue delete_catalog "$catalog" done