Skip to content

Instantly share code, notes, and snippets.

@vi7
Created April 4, 2024 16:47
Show Gist options
  • Save vi7/4ab4bc7b4b19cb67acef954c9b941e75 to your computer and use it in GitHub Desktop.
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
#!/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