Rta data needs regexp

Hi

echo "rta=58.124001ms;100.000000;150.000000;0.000000"

I required 58.12 and 0.00 i,e from first and last.

I tried using : awk -F"rta=" '{print $2}' and last one awk -F";" '{print $4}' but unsuccessful.

Thanks

awk -F"[=;]" ' { print $2, $NF } ' 
1 Like
echo "rta=58.124001ms;100.000000;150.000000;0.000000 pl=0%;5;15;0" | awk -F"[=;]" ' { print $2, $NF } '
58.124001ms 0

I just required 58.12 and 0.00 - Could you please assist.

awk -F"[=;]" ' { printf("%.2f %.2f",$2, $NF) } ' 
1 Like
cat file1 | awk -F"[=;]" '{ print $2,$NF }' | cut -c 1-5," ",13-16
1 Like

You didn't print that desired 0.000000 but the last single 0 that was not present in your post #1's sample.

rta=58.124001ms;100.000000;150.000000;0.000000 pl=0%;5;15;0"
                                      ^-desired           ^-printed

With this sample, even anbu23's formatted printout would not deliver the correct value. If the correct value is last in line, the proposals will work fine, if it's not, you need to supply more conditions how to identify it.