Skip to content
Snippets Groups Projects

Bash Extract IP(s) from `ip a`

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Roman Geber

    Using nothing bot GNU core utils to extract the IP of ip addr

    Specify a device in first command for specific IP if needed.

    extract_ip.sh 98 B
    #!/bin/bash
    
    ip addr | grep inet | grep -v 127.0.0.1 | cut -c 5- | cut -d " " -f 2 | cut -d / -f 1
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment