1 2 3 4 5 6 7 8 9
#!/bin/bash IP_ADDRESS=$(ip route get 1 | awk '{print $NF;exit}') if [[ "${IP_ADDRESS}" != "" ]]; then echo "${IP_ADDRESS}" echo "${IP_ADDRESS}" echo "" fi