Extract version number from a string

前端 未结 5 2072
灰色年华
灰色年华 2020-11-29 12:40

I have a string with components and version numbers:

data-c(kuh-small1);divider-bin-1.4.4;divider-conf-1.3.3-w(1,16);storage-bin-1.5.4;storage-conf-1.5.0-w(1);

5条回答
  •  误落风尘
    2020-11-29 13:11

    sed -n "s/.*;divider-bin-\([0-9][^;]*\);.*/\1/p"
    

    infos is between ;divider-bin- and next ; and start with a digit. This is to ensur that no Other-divider-bin- or divider-bin-and-hex- will interfere with your request. Also, return empty string if not find. to be exhaustif (assuming version is only digit and dot)

    sed -n "s/.*;divider-bin-\([0-9.]\{1,\}\)\([^0-9.;][^;]*\)*;.*/\1/p"
    

提交回复
热议问题