Skip to content

Instantly share code, notes, and snippets.

@fr0gs
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fr0gs/6fd7307e49112fcb4f58 to your computer and use it in GitHub Desktop.
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
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