#!/bin/bash ip=$(ip -json route get 8.8.8.8 | jq -r '.[].prefsrc') echo $ip