#!/bin/bash fl="$1" if [[ "${fl}X" == "X" ]] then echo "Usage: $0 " exit fi if [[ ! -f ${fl} ]] then echo "Usage: $0 " exit fi filetype=$(file ${fl} | grep ASCII) if [[ "X" != "${filetype}X" ]] then CMD='cat' else filetype=$(file ${fl} | grep 'gzip compressed data') if [[ "X" != "${filetype}X" ]] then CMD='zcat' else echo "Usage: $0 " exit fi fi ${CMD} $1 | grep IP= | awk '{print $10}' | awk -F':' '{print $1}' | sort -u | sed 's/IP=//' | while read line do name=$(dig -x ${line} +short) echo "${line} ${name}" done