zeek/auxil/zeekctl/testing/Scripts/diff-to-bytes-output
Patrick Kelley 8fd444092b initial
2025-05-07 15:35:15 -04:00

25 lines
521 B
Python
Executable File

#! /usr/bin/env python3
#
# Convert large integers in the to-bytes.awk output to floating point
# exponential format, because some versions of awk output large integers in
# that format.
import sys
bignumber = 2**31 - 1
for line in sys.stdin:
outstr = ""
for field in line.split():
try:
num = float(field)
except ValueError:
num = 0
if num > bignumber:
outstr += f"{num:.5e} "
else:
outstr += f"{field} "
print(outstr[:-1])