--version VS -version VS -v

I have been using linux for some time and whenever I need to find the version of some package, I need to either do --version or -version or -v.

python --version
npm -v

Also, I have noticed the case where -v is used, we can also use --version and -version.


Solution 1:

If you want to see the version of an installed package, why don't you simply ask the package manager?

sh@balrog:~$ dpkg -l python
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                Version        Architecture   Description
+++-===================-==============-==============-===========================================
ii  python              2.7.15~rc1-1   amd64          interactive high-level object-oriented lang
sh@balrog:~$ apt list python
Listing... Done
python/bionic,now 2.7.15~rc1-1 amd64 [installed]

If you don't know what package a program belongs to, again, ask the package manager:

sh@balrog:~$ dpkg -l xdpyinfo
dpkg-query: no packages found matching xdpyinfo

Duh... that must be in a different package...

sh@balrog:~$ dpkg -S $(which xdpyinfo)
x11-utils: /usr/bin/xdpyinfo
sh@balrog:~$ dpkg -l x11-utils
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                Version        Architecture   Description
+++-===================-==============-==============-===========================================
ii  x11-utils           7.7+3build1    amd64          X11 utilities