Last active
November 26, 2019 08:10
-
-
Save vertexvaar/3ae4f32157cf1cc9035b8cdb2bebf064 to your computer and use it in GitHub Desktop.
Get primary IP address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| echo "The hostname way" | |
| echo $(hostname --all-ip-addresses | cut -d' ' -f1) | |
| echo "more complicated but stable" | |
| echo $(ifconfig $(/sbin/ip route | grep -v tun | awk '/default/ { print $5 }') | awk -F ' *|:' '/inet /{print $3}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment