Advertisement: Linux VPS from $4/month - contact support for custom offer.
+ Post New Thread
Results 1 to 1 of 1

Thread: Extract/print app version number (separated by dots) out of a string on Linux

  1. #1
    Administrator
    Join Date
    Mar 2013
    Posts
    2,780

    Extract/print app version number (separated by dots) out of a string on Linux

    This Linux command should work to extract first occurrence of a version number out of a string.

    command:

    echo "airdcpp_2.12.2_webui-2.12.1_64-bit_portable.tar.gz" | grep -oP '\d+(\.\d+)*' | head -n 1

    returns:
    2.12.2

    To return version of some Debian/Ubuntu package, this may work:

    dpkg -s nicotine | grep '^Version:' | awk '{print $2}' | awk -F'-' '{print $1}'

    awk after the last pipe splits the version string on the hyphen (-) and prints the first part, effectively removing any subversion
    Last edited by Fli; 10-03-2024 at 09:45 AM.

+ Post New Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
 Protected by : ZB BLOCK  &  StopForumSpam