Skip to main content
Question

Display more than two MAC addresses as an Attribute

  • April 12, 2018
  • 1 reply
  • 2 views

Forum|alt.badge.img+3

Hi All,

Can anyone tell me what is wrong with this script.
I am trying to get it to display more than the default two MAC addresses.

!/bin/bash

allNetworks=`networksetup listallhardwareports | awk 'BEGIN { RS=""; FS=""; } /
Port: (Wi-Fi|Thunderbolt|Ethernet|Display).*? Device: en([a-z0-9]+) Ethernet
Address: (([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2}))/ { print $0; }' | awk '/(([0-9A-
Fa-f]{2}:){5}([0-9A-Fa-f]{2}))/ { print $3; }' | awk '{ print toupper($0) }'`

printf "<result>"

for line in $allNetworks
do printf "$line|"
done

printf "</result>"

1 reply

DBrowning
Forum|alt.badge.img+25
  • Esteemed Contributor
  • April 12, 2018

i do this

#!/bin/sh

list=$(networksetup -listallhardwareports)

echo "<result>$list</result>"

for a result that looks like below