#!/bin/bash RESOLVE=0 TOP="10000" HELP="$0 [--resolve|-r] [--top|-t N] port1 ... portN" PORTS="" while [[ "$1" != "" ]] do if [[ "$1" = "--help" || "$1" = "-h" ]] then echo $HELP exit elif [[ "$1" = "--resolve" || "$1" = "-r" ]] then RESOLVE=1 elif [[ "$1" = "--top" || "$1" = "-t" ]] then shift TOP=$1 else PORTS="$PORTS $1" fi shift done for port in $PORTS do name=$(egrep " $port/tcp" /etc/services | awk '{printf $1" "}') cat <