Skip to content

Instantly share code, notes, and snippets.

@NanXiao
Created February 7, 2020 10:43
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 NanXiao/2616fe2fee5c8578b843e05f2832b594 to your computer and use it in GitHub Desktop.
Save NanXiao/2616fe2fee5c8578b843e05f2832b594 to your computer and use it in GitHub Desktop.
#!/usr/bin/awk -f
BEGIN {
FS = ",";
}
function update_array(ticket, full_array, partial_bytes_array)
{
if (length(ticket) != 0)
{
partial_bytes_array[substr(ticket, 1, 16)]++;
full_array[ticket]++;
}
}
function array_elem_num(array)
{
elems_num = 0;
for (ticket in array)
{
if (array[ticket] > 1)
{
elems_num++;
}
}
return elems_num;
}
{
update_array($3, session_ticket_full_array, session_ticket_partial_bytes_array);
update_array($4, session_ticket_full_array, session_ticket_partial_bytes_array);
}
END {
printf "Array element number (use full ticket): %d\n", array_elem_num(session_ticket_full_array);
printf "Array element number (use first 8 bytes of ticket): %d\n", array_elem_num(session_ticket_partial_bytes_array);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment