Re: How to grab version number?



On Tue, 05 Dec 2006 20:33:51 +0000, Stephane CHAZELAS wrote:

lighttpd-1.4.10 (ssl) - a light and fast webserver

How could I grab only the version, which is only the (first) group of
numbers separated by dots?

be careful what you ask for!

NL='
'
string='lighttpd-1.4.10 (ssl) - a light and fast webserver'
printf '%s\n' "$string" |
sed "
s/\([0-9]\{1,\}\(\.[0-9]\{1,\}\)\{1,\}\).*/\\$NL\1/
s/.*\n//"

Or:

perl -le 'print $ARGV[0] =~ /(\d+(?:\.\d+)+)/' -- "$string"

Stephane's answer is exactly what you asked for -- the (first) group of
numbers separated by dots.

IMHO, when talking about version numbers, what you asked for might not be
(totally) correct. There might be underlines, or even characters. E.g.,
here is a (very limited) list of all forms a Debian version number may
looks like:

foomatic-filters_3.0.2-20061031-1
gimp_2.2.13-1
gimp-data_2.2.13-1
gs-esp_8.15.3.dfsg.1-1
libcupsys2_1.2.5-1
libgimp2.0_2.2.13-1

I know yours may not, but just be cautious.

--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/


--
Posted via a free Usenet account from http://www.teranews.com

.



Relevant Pages

  • Re: dot count
    ... Dave Thomas wrote: ... Be very careful with dots in Excel. ... beside a cell filled with ellipses, you will see the spacing between the ...
    (microsoft.public.excel.worksheet.functions)
  • Re: dot count
    ... Be very careful with dots in Excel. ... beside a cell filled with ellipses, you will see the spacing between the ... cells look different.There is a slightly wider space following the ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Using wild card in DateTime
    ... Bob Barrows wrote on 22 apr 2004 in microsoft.public.inetserver.asp.db: ... not tested, please be careful ... The Netherlands. ... (Please change the x'es to dots in my emailaddress) ...
    (microsoft.public.inetserver.asp.db)
  • Re: Menu bar is missing otlook express 6
    ... How can I restore it? ... On the left end of the toolbar is a vertical line of dots. ... Grab it with the mouse and drag it down. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)