0

This question already has an answer here:

Please answer as generally as possible, but here is the exact problem:

Ubuntu: 
packagename: gnupg2
executable: gpg
version: 2.1.18

Debian:
packagename: gnupg
executable: gpg
version: 1.4.20

How to get gpg (or gpg1 / gpg2) from gnupg (or gnupg1 / gnupg2) This issue is because I'm writing something for debian and also ubuntu. (or other systems). I din't found it in neither dpkg or apt-cache. Maybe some special magic words???

EDIT:

dpkg -L is a good answer, thank you @PerlDuck, but as @cmak.fr mentioned, I would like to get main executable file name. Do you know simple way how to select (grep) the main one? I could use:

dpkg -L gnupg | egrep '\/gpg$|\/gpg[12]$' | egrep -o 'gpg[12]$|gpg$'

But it's only for case when I know possible names (fortunately, you usually know them).

Thank you

marked as duplicate by dessert command-line Jun 21 '18 at 10:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Are you asking how to list the names of all executables in a given package? Like How do I get a list of installed files from a package?? – PerlDuck Jun 21 '18 at 10:01
  • 2
    As this seems to answer your question quite well I’ll close it as a duplicate, if it doesn’t please edit your question, clarify and ping me. To get a list of executable files I’d use for i in $(dpkg-query -L gnupg2); do [[ -f "$i" && -x "$i" ]] && echo $i; done. Note that many packages contain more than one executable, exactly like gnupg2 does. – dessert Jun 21 '18 at 10:13
  • 1
    You want to automatically guess the main executable file name... Perhaps use host properties (os name, version...) and package name to try and test some guesses... – cmak.fr Jun 21 '18 at 10:43
  • @cmak.fr Thank you, I'll most probably do that. At first check for system and than use possible guesses. – Kvader Jun 21 '18 at 11:19
  • 1
    There's no canonical way to relate a package archive and the “main binary executable” file within it (if any). – David Foerster Jun 21 '18 at 13:54