bash regex to match semantic version number -
i have following:
versionnumber=$(sw_vers -productversion) # finds version number versionshort=${versionnumber:0:4} # cutting string 1 decimal place calculation
which works when versions this:
10.9.2 10.9.5
but not match
10.10.3
as homecoming only
10.1
but want versionshort set
10.10
i wanting match major version, first dot , minor version above.
regexpless solution - cutting off lastly dot , whatever follows it:
versionshort=${versionnumber%.*}
regex bash
No comments:
Post a Comment