Last active
August 29, 2015 14:17
-
-
Save fr0gs/6fd7307e49112fcb4f58 to your computer and use it in GitHub Desktop.
Crappy code to read a pcap file with tcptrace and convert elapsed time into seconds
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
TIMEZ=$(tcptrace -l $PCAP 2>/dev/null | awk 'NR==15 {print $3}') # Got a time value like 00:00: | |
OIFS="$IFS" | |
IFS=':' | |
read -a tokenized <<< "${TIMEZ}" | |
IFS="$OIFS" | |
HOUR=( "${tokenized[0]}" ) | |
MIN=( "${tokenized[1]}" ) | |
SEC=( "${tokenized[2]}" ) #To reassign a variable assigned | |
RES=$(echo "scale = 6; 3600*$HOUR+60*$MIN+$SEC" | bc) | |
echo $RES |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment