Created
June 2, 2019 10:05
-
-
Save double-p/9e71a63b9969b4669d04ee57591a8433 to your computer and use it in GitHub Desktop.
This file contains 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
# ifconfig output like | |
tap0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 | |
lladdr fe:e1:ba:d3:98:45 | |
description: vm1-if0-myvm | |
index 73 priority 0 llprio 3 | |
groups: tap | |
status: active | |
inet 100.64.1.2 netmask 0xfffffffe | |
tap1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 | |
lladdr fe:e1:ba:d4:a7:78 | |
description: vm2-if0-myvm2 | |
index 74 priority 0 llprio 3 | |
groups: tap | |
status: active | |
inet 100.64.2.2 netmask 0xfffffffe | |
tap2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 | |
lladdr fe:e1:ba:d5:ad:bd | |
description: vm3-if0-3myvm | |
index 75 priority 0 llprio 3 | |
groups: tap | |
status: active | |
inet 100.64.3.2 netmask 0xfffffffe | |
parse.awk: | |
BEGIN { tap_name = "" ; tap_ip = ""; tap_found = "" } | |
$1 ~ /tap/ { | |
tap_name = $1 | |
} | |
$2 ~ /vm2-if0-myvm2/ { | |
tap_found = 1 | |
} | |
$1 ~ /inet/ { | |
if (tap_found == 1) { | |
tap_ip = $2 | |
printf("name: %s ip: %s\n", tap_name, tap_ip) | |
exit | |
} | |
} | |
== | |
ssfnhv011$ awk -f parse.awk < tapconfig | |
name: tap1: ip: 100.64.2.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment