OUT=$(ping -c 2 192.168.1.1)
PING gw (192.168.1.1) 56(84) bytes of data.
64 bytes from gw (192.168.1.1): icmp_seq=1 ttl=64 time=0.156 ms
64 bytes from gw (192.168.1.1): icmp_seq=2 ttl=64 time=0.143 ms
VAR=??
OUT=$(ping -c 2 192.168.1.1)
VAR=$(echo $OUT | grep -Po '(\d{1,3}\.){3}\d{1,3}' | head -1)