On Sat, Feb 08, 2003 at 02:16:53AM +0100, Moritz Bunkus wrote:
[Automatic answer: RTFM (read DOCS, FAQ), also read DOCS/bugreports.html] Hi.
echo 1.1 | sed -e 's/^\([0-9]+\)\.\([0-9]+\).*/\1\2/'
After some hints from the local Unix gurus I now know why this breaks: sed uses BREs (basic regular expressions, see man 7 regex) which simply do not know the + operator. awk uses ERE (extended RE), and the most powerful are the PRE (Perl RE).
On the other hand: Note that version numbers which have two digits subversion will break comparison ;) 1.10 --> 110 > 21 = 2.1 :)
echo $[`echo "$ver" | sed 's/[.]/*100+/'`] Replace 100 by 1000 if you think some idiot will make ver 1.101 or some nonsense... (maybe a typo for 1.10l? ;) more like 100000l to whoever the idiot was who came up with using strings for version numbers...) Rich