Search code examples
sedgrepsubstringvmware-workstation

Extracting version number substring


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)?


Solution

  • Another way of doing it with grep:

    vmware-installer -l | grep -Po "(\d+\.){2}\d+"