The bellow regexp will match any floating number in the format [0-9].[0-9]
and will return the integer part of this floating number.
$ a="scalar TestDmaMac4.sink.udpApp[0] throughput:last 11730.559888477"
$ egrep -o '[0-9]+[.][0-9]' <<<"$a" |egrep -o '[0-9]+[^.]' #First grep will isolate the floating number , second grep will isolate the int part.
11730
$ perl -pe 's/(.*?)([0-9]+)(\.[0-9]+.*)/\2/' <<<"$a" #using the lazy operator ?
11730
$ sed -r 's/(.*[^0-9.])([0-9]+)(\.[0-9]+.*)/\2/' <<<"$a" #sed does not have lazy operator thus we simulate this with negation
11730
For the sake of testing, i also tried above regexp in a different string with floatting number at different position without a leading space:
$ c="scalar throughput:last11730.559888477 TestDmaMac4.sink.udpApp[0]"
$ egrep -o '[0-9]+[.][0-9]' <<<"$c" |egrep -o '[0-9]+[^.]'
11730
$ perl -pe 's/(.*?)([0-9]+)(\.[0-9]+.*)/\2/' <<<"$c"
11730
$ sed -r 's/(.*[^0-9.])([0-9]+)(\.[0-9]+.*)/\2/' <<<"$c"
11730
-P
is available as shown in accepted answer in that question... or using sed/awk etc... do add the command you tried but failed... we can help you correct it – Sundeep Apr 13 '17 at 15:13awk '{print int($NF)}'
– steeldriver Apr 13 '17 at 17:11egrep -o '[0-9]+\.' | tr -d .
– thrig Apr 13 '17 at 18:50