#!/bin/bash
FILE=$1
while read LINE; do
ttlstr=$(ping -c1 -w1 $LINE | grep -o 'ttl=[0-9][0-9]*') || {
printf "%s is Offline\n" "$LINE"
continue;
}
ttl="${ttlstr#*=}"
printf "%s is Online, ttl=%d\n" "$LINE" "$ttl"
done < $FILE
file addr.txt
192.168.2.1
8.8.8.8
10.9.9.9
4.4.4.4
9.9.9.9
1.1.1.1
Запуск и вывод результатов
root@ubnt:~# ./pingffile.sh addr.txt
192.168.2.1 is Offline
8.8.8.8 is Online, ttl=110
10.9.9.9 is Offline
4.4.4.4 is Offline
9.9.9.9 is Online, ttl=59
1.1.1.1 is Online, ttl=58