Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.