#!/bin/bash set -euo pipefail if gpg --fingerprint --with-colons 'test@example.com' | grep "example.com" ; then echo Key for test@example.com exists exit fi todelete() { gpg --fingerprint --with-colons 'test@example.com' |\ grep "^fpr" |\ sed -n 's/^fpr:::::::::\([[:alnum:]]\+\):/\1/p' } #while read line; do # gpg --yes --delete-secret-keys "$line"