#!/usr/bin/env bash # # Extracts the IP address from the first 'Received:' header dir="$1" if [ -z $dir ]; then echo "Usage: $(basename $0) " exit 1 fi for spammail in $(find "$dir" -type f); do grep '^Received:' $spammail | tail -1; done | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'