awk

  • Seperate input fields by colon, return output separated by space, save into an array
gpg -k --with-colons \
	| grep '^...:e' \
	| awk -F ':' '{ print $5 }' \
	| awk -v ORS=' ' 'NF' \
	| read -A array

gpg --delete-keys ${array}