You’ll need to use some scripting knowledge here - the idea is to print out the names of groups which match the query, and feed that into a loop which runs the delete command.
Any time you automate a command over a set of resources, make sure you get the query part right first. Experiment with the --query
parameter and you’ll see you can filter the matching resources and also select just part of the response in the output.
Need more? Here’s the solution.