From 0668b3614d69a9b65b91c3dfb62c69ab05a79b1b Mon Sep 17 00:00:00 2001 From: moshix Date: Sun, 16 Apr 2023 19:32:34 +0200 Subject: [PATCH] parses all common Macos interfaces for valid IP4 assignments and prints them in tabular form (for easy awk further processing) --- nicparseMacos.bash | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 nicparseMacos.bash diff --git a/nicparseMacos.bash b/nicparseMacos.bash new file mode 100644 index 0000000..be00078 --- /dev/null +++ b/nicparseMacos.bash @@ -0,0 +1,47 @@ +#!/bin/bash +# Macos all addresses parser +# Copyright 2023 by Moshix - All right reserved +# You may only execute this script but not redistribute or enhance without first including the full +# script in its entirety as comment in your own changes or enhancements +# v 0.1 Humble beginnings +# v 0.2 Exclude non IP4 interfaces + +for counter in 0 1 2 3 4 5 6 ; +do + result=`ifconfig vmenet"$counter" 2>/dev/null` + if grep -q "inet " <<< "$result"; then + echo -n -e "NIC vmenet$counter:\t" + ifconfig vmenet"$counter" | grep "inet " | awk '{print $2}' + fi +done + + +for counter in 0 1 2 3 4 5 6; +do + result=`ifconfig en"$counter" 2>/dev/null` + if grep -q "inet " <<< "$result"; then + echo -n -e "NIC en$counter:\t" + ifconfig en"$counter" | grep "inet " | awk '{print $2}' + fi +done + + + +for counter in 0 1 2 3 4 5 6; +do + result=`ifconfig utun"$counter" 2>/dev/null` + if grep -q "inet " <<< "$result"; then + echo -n -e "NIC utun$counter:\t" + ifconfig utun"$counter" | grep "inet " | awk '{print $2}' + fi +done + + +for counter in 100 101 102 103 104; +do + result=`ifconfig bridge"$counter" 2>/dev/null` + if grep -q "inet " <<< "$result"; then + echo -n -e "NIC bridge$counter:\t" + ifconfig bridge"$counter" | grep "inet " | awk '{print $2}' + fi +done