Skip to content

Instantly share code, notes, and snippets.

@dualbus
Created December 8, 2013 17:40
Show Gist options
  • Save dualbus/7860779 to your computer and use it in GitHub Desktop.
Save dualbus/7860779 to your computer and use it in GitHub Desktop.
#!/bin/sh
ip -o addr \
| awk '
$2 ~ /:$/ {
i=$2;
sub(/:$/,"",i);
status[i]=$9
}
$3 == "inet" {
ipv4_address[$2]=$4
}
END {
general_status=0
for(interface in status) {
if(status[interface] == "UP") {
general_status++;
print interface;
}
}
exit(! general_status);
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment