#!/bin/bash
if [ $# -eq 0 ];then
IPLINE=`seq $(cat host.txt|wc -l)`
elif [ $# -eq 1 ];then
KEYVAR=`echo $1|tr "," "|"`
IPLINE=`cat host.txt|grep -En "$KEYVAR"|awk -F ":" '{print $1}'`
elif [ $# -gt 1 ];then
echo "Error! The style:$0 IP1,IP2,IP3...."
exit
fi
for i in $IPLINE
do
sed -n "$i"p host.txt
echo "-----------"
done