1 2 3 4 5 6
#!/bin/sh if [ "_$(uname -s)" != "_Linux" ];then /sbin/route -n get "$1" | grep "local addr" | cut -d: -f2 | tr -d ' ' else /sbin/ip r g "$1" | cut '-d ' -f8 fi