Заказчик просит странного. Поэтому приходится извращаться:
#!/bin/bash
NOW="`date +%H:%m:%S` "
FILENAME="`date +%d%m%Y`.txt"
if [ $(date +%k%M) -ge 800 ] && [ $(date +%k%M) -lt 1000 ] ; then
HOST1=`fping 172.18.18.101 -A 2>/dev/null|grep alive`
HOST2=`fping 172.18.18.102 -A 2>/dev/null|grep alive`
HOST3=`fping 172.18.18.103 -A 2>/dev/null|grep alive`
HOST4=`fping 172.18.18.104 -A 2>/dev/null|grep alive`
HOST5=`fping 172.18.18.105 -A 2>/dev/null|grep alive`
HOST6=`fping 172.18.18.106 -A 2>/dev/null|grep alive`
HOST7=`fping 172.18.18.107 -A 2>/dev/null|grep alive`
if [ -n "$HOST1" ]; then
echo $NOW $HOST1 >> /root/pc_is_alive/$FILENAME
fi
if [ -n "$HOST2" ]; then
echo $NOW $HOST2 >> /root/pc_is_alive/$FILENAME
fi
if [ -n "$HOST3" ]; then
echo $NOW $HOST3 >> /root/pc_is_alive/$FILENAME
fi
if [ -n "$HOST4" ]; then
echo $NOW $HOST4 >> /root/pc_is_alive/$FILENAME
fi
if [ -n "$HOST5" ]; then
echo $NOW $HOST5 >> /root/pc_is_alive/$FILENAME
fi
if [ -n "$HOST6" ]; then
echo $NOW $HOST6 >> /root/pc_is_alive/$FILENAME
fi
if [ -n "$HOST7" ]; then
echo $NOW $HOST7 >> /root/pc_is_alive/$FILENAME
fi
fi
cat /root/pc_is_alive/12092014.txt
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
09:09:01 172.18.18.101 is alive
09:09:01 172.18.18.103 is alive
09:09:01 172.18.18.104 is alive
Подскажите, почему таймстемп у строк одинаковый?