Re: How to grab version number?
- From: * Tong * <sun_tong_001@xxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 05 Dec 2006 17:26:22 -0500
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
.
- Follow-Ups:
- Re: How to grab version number?
- From: Charles A. Landemaine
- Re: How to grab version number?
- References:
- How to grab version number?
- From: Charles A. Landemaine
- Re: How to grab version number?
- From: Stephane CHAZELAS
- How to grab version number?
- Prev by Date: Re: find: missing argument to `-exec'
- Next by Date: Re: Extract runtime from logfile
- Previous by thread: Re: How to grab version number?
- Next by thread: Re: How to grab version number?
- Index(es):
Relevant Pages
|