Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2019
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.80 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. awk '{
  4.         for(i=1; i<=NF; i++) {
  5.                 tmp=match($i, /^[0-9]*s[0-9]*ms$/)
  6.                 tmp2=match($i, /^[0-9]*ms$/)
  7.                 if(tmp) {
  8.                   j = index($i, "s")
  9.                   k = index($i, "ms")
  10.                   seconds = substr($i, 0, j-1)
  11.                   miliseconds = substr($i, j+1, k-j-1)
  12.                   newtime = seconds + miliseconds/1000
  13.                   printf("%.02f ", newtime)
  14.                 } else if (tmp2) {
  15.                   k = index($i, "ms")
  16.                   miliseconds = substr($i, 0, k-1)
  17.                   newtime = miliseconds/1000
  18.                   printf("%.02f ", newtime)
  19.                 }
  20.                 else {
  21.                   printf $i " "
  22.                 }
  23.         }
  24.         printf "\n"
  25. }' $1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement