#!/bin/bash
#
#   scavenge-grid.sh
#
#   Try to find the grid for a call from an ALL.TXT log.
#
#

# first argument: the call
if [ -z "$1" ]; then
	echo "Usage: $0 <call> [<file> ...]"
	exit 1
fi

# search: find all grid-looking transmissions from the call, then print the last one
grep -i " $1 [A-Z][A-Z][0-9][0-9]$" ${@:2} | grep -v 'RR73' | tail -1 | awk '{ print $(NF) }'

# EOF
