Thursday, March 11, 2010

awk: regular expressions and group submatch capture

b=`ssh root@registration.authinfra.net 'rpm -qg pi'`

echo $b | awk 'match($0, "pi-multihome-[[:digit:]].[[:digit:]]-([[:digit:]]*)", a) {print a[1]}'

OUTPUT: 125324

No comments: