Skip to content

Instantly share code, notes, and snippets.

@flandr
Created April 22, 2015 18:39
Show Gist options
  • Save flandr/082c6453ec97b4e3ed7f to your computer and use it in GitHub Desktop.
Save flandr/082c6453ec97b4e3ed7f to your computer and use it in GitHub Desktop.
awk ternary example
# Data:
# 1ms foo
# 3.7s bar
# ...
# Convert to seconds
gawk 'BEGIN {FS=" +"} { val = $1 ~ /ms$/ ? $1 / 1000 : $1 * 1; print val,$2 }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment