79185020

Date: 2024-11-13 13:12:15
Score: 0.5
Natty:
Report link

There are quite few 'jq' solutions around. Within my searches, this one from @JanB impressed the most.

Other people have outlined about how to extract floating point numbers from text. This one on Stack for instance.

In the end I wrote a short script program with a CLI interface that can be run as standalone or embedded.

floatversion -M "$(curl -sf "https://github.com/TuxVinyards/floatversion/releases" | grep 's/tag')"
1.0.0

floatversion -r "$(curl -sf https://github.com/qemu/qemu/tags | grep 's/tag')"
9.1.1  9.1.0  9.0.3  8.2.7  7.2.14  

floatversion -M "$(curl -sf https://github.com/qemu/qemu/tags | grep 's/tag')"
9.1.1
  floatversion --options  "quoted-input-source"

  Extracts point separated numbers, or semantic version numbers with optional suffixes,
  and other common variations upon, from a given string or text-file

  -h | --help         show help 
  -V | --version      show version
  -c | --col          show list as column instead of string (unless -M)
  -r | --rev          show list in reverse order  
  -a | --all          show all extracted values, not just unique 
  -n | --num          sort by standard numbering, not versioning
  -f | --full         check for additional sem. ver. suffixes,  eg. -beta
  -F | --filter       contains given items -F  "string  string  string" 
  -S | --starts       starting with -S  "string  string  string" 
  -D | --delete       doesn't contain: -D  "string  string  string" 
  -M | --max          outputs the highest/latest value in list, only, with '-r' shows lowest/earliest
  -g | --gt           A > B, returns true/false -g "A B" (.nums or sem ver, for -lt use B A)
  -v | --verbose      for problem output, show algorithm sequences (full version only) 
       --sort-v       use sort -V (if present) in preference to the default jq methods
       --no-svb       no falling back to 'jq' if 'sort -V' is unavailable, show error instead

  Without options, produces a single sorted string of all unique items found
  Filters output as string, column or max. Post-output grep requires columns.

  Tests show 'jq' sort methods as more reliable than 'sort -V' esp. with alpha suffixes
  All cases, returns false if none

On GitHub here

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @JanB
  • Low reputation (1):
Posted by: Alex_123XYZ