List file's encryption keys with --with-colons?

schalox schalox at gmail.com
Fri Apr 25 14:28:22 CEST 2014


Hi,

When using --list-keys, you can do this:
gpg --list-keys --with-colons "${GPG_RECIPIENTS[@]}" |
    grep '^sub:' | cut -d ':' -f 5 | sort -u

Can you do the same with --list-only to get the (long versions of)
encryption keys in a colon-separated output?

Currently we're using this:
gpg -v --list-only --keyid-format long "$file" 2>&1 |
    cut -d ' ' -f 5 | sort -u

We know of FAQ's method[0], but we'd like to know if there's a better
way to do this.

[0] http://www.gnupg.org/faq/GnuPG-FAQ.html#how-can-i-get-list-of-key-ids-used-to-encrypt-a-message



More information about the Gnupg-users mailing list