#! /bin/bash FILE="dd/conf/ips.txt" OUTDIR="dd/logs" #FILE=$IPFILE #OUTDIR=$LOGSDIR while read LINE; do IP=$(echo $LINE | cut -d" " -f1) NAME=$(echo $LINE | cut -d" " -f2) echo "Name=$NAME, IP=$IP" ping $IP -c 1 > /dev/null || echo "$(date +"%D - %H:%M:%S"): $NAME down" >> $OUTDIR/$NAME done < "$FILE"