Another way of doing it with grep:
vmware-installer -l | grep -Po "(\d+\.){2}\d+"
سؤال
I have this:
Product Name Product Version
==================== ====================
vmware-workstation 9.0.2.1031769
I can get the vmware-workstation
part with a:
$ vmware-installer -l | grep -Po "(?=v)[^ ]*(?= )"
How do I get the version number part (without the build, meaning just 9.0.2
)?
المحلول
Another way of doing it with grep:
vmware-installer -l | grep -Po "(\d+\.){2}\d+"
نصائح أخرى
With sed:
vmware-installer -l | sed -n 's/[^ ]* *\(.*\)\.[0-9]*/\1/p'
$ vmware-installer -l | grep -Po "^v\S+\s+\K\d+\.\d+\.\d+"
9.0.2
$ vmware-installer -l | grep -Po "(?:\d+\.){2}\d+"
9.0.2
this :
(?:)
avoid not needed capturing groups