As for:
$ dpkg -f <deb-file> <field>
there is something that likewise:
$ apt-cache show <package> <field>
returns me a field of a package?
For example, assuming I have discord already installed and its .deb archive in the current directory, I run the commands:
$ dpkg -f ./discord.deb Version
$ apt-cache show discord Version
Outputs I'd like:
0.0.27
0.0.27
Actual output:
0.0.27
... # discord package unwanted long output
N: Unable to locate package Version
I'd like a solution that makes use of the apt-cache or dpkg command itself.
In the absence of such a solution, then I accept the usual parser.
How do I solve?
EDIT 1:
I only want to display the installed version of a package.
To show only the installed version of a package: (and subsequently, this only works for installed packages)
To include a line break, just include a newline in the format string:
This one-liner extracts the version of a package: