File: get-interface-ipv4

package info (click to toggle)
yuma123 2.14-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 22,436 kB
  • sloc: ansic: 185,144; cpp: 10,968; python: 7,990; sh: 2,676; makefile: 1,175; xml: 807; exp: 776; perl: 70
file content (11 lines) | stat: -rwxr-xr-x 232 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
#!/bin/sh

ip=`ip -4 addr show $1 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'`

if [ "$ip" = "" ] ; then
    exit 0
fi

echo -n '<ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip"><address><ip>'
echo -n "$ip"
echo '</ip></address></ipv4>'