Created
April 4, 2024 16:47
-
-
Save vi7/4ab4bc7b4b19cb67acef954c9b941e75 to your computer and use it in GitHub Desktop.
Oneliner to get IP address of the interface in Linux. Uses ip and jq commands
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
#!/usr/bin/env bash | |
INTERFACE_NAME=eth0 | |
ip -family inet -json addr show $INTERFACE_NAME | jq --raw-output .[0].addr_info[0].local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment