File: file.txt
Iteration 1
RAM: +2s342ms (total +417ms)
Iteration 2
RAM: +2s (total +385ms)
Iteration 3
RAM: +149ms (total +185ms)
The code was taken from https://stackoverflow.com/a/54702959/10220825
try.awk
/:/ && $2 ~/ms$/{vals[$1]=vals[$1] OFS $2+0;next}
/:/ && $2 ~/[^m]s$/{vals[$1]=vals[$1] OFS ($2+0)*1000}
END {
for (key in vals)
print key vals[key]
}
On executing: awk -f try.awk file.txt
Expected output:
RAM: 2342 2000 149
Output:
RAM: 2 2000 149
Please help in fixing the above code to convert s
to ms
, the problem I am facing when the value is mixed of s
and ms
.