Get application version name using adb
adb shell dumpsys package my.package | grep versionName
as mentioned by @david and @Jeremy Fishman. This will be much quicker than:
adb shell dumpsys | grep -A18 "Package \[my.package\]"
In case someone needs all apps versions for comparing purposes then here is my oneliner:
for p in `adb shell pm list package | awk -F"package:" '{print $2}'`; do echo -n "$p: "; adb shell dumpsys package $p | grep -i versionName | awk -F"=" '{print $2}'; done
Maybe it will be helpful for somebody but please note that I use versionName and ignore versionCode, so use with care.
Dumpsys package is your friend
~/# adb shell
shell@mo:/ dumpsys package tld.comp.app_name | grep version
Will return
versionCode=X targetSdk=YY
versionName=Z.Z