I'm trying to remove all unused images with specific name format from Kubernetes cluster like below.
crictl images | grep -E -- 'foo|bar' | awk '{print \$3}' | xargs -n 1 crictl rmi
But this one also deletes all the images with naming "foo" or "bar" even it's in use by container. Tried using "crictl rmi -q" but that deletes multiple other images which are not in the filter above.