Created
October 17, 2018 07:40
-
-
Save mutsune/6f5904f3bd9eab380deaf95f6f2f3689 to your computer and use it in GitHub Desktop.
Convert `ps -o etime` format into seconds https://stackoverflow.com/a/14653443
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
BEGIN { FS = ":" } | |
{ | |
if (NF == 2) { | |
print $1*60 + $2 | |
} else if (NF == 3) { | |
split($1, a, "-"); | |
if (a[2] != "" ) { | |
print ((a[1]*24+a[2])*60 + $2) * 60 + $3; | |
} else { | |
print ($1*60 + $2) * 60 + $3; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment