mac2dev() {
# This got long
ifconfig | while IFS= read _line; do
if [[ "$_line" = [a-z]!(\ *):* ]]; then
_dev=${_line%%:*}
elif [[ "$_line" = *lladdr*$1* && $_dev != vlan* ]]; then
echo $_dev
fi
done
}
_if=$(mac2dev "$_mac") # or just _if=$(mac2dev ${_hn#*.})
My solution would have been:
_if=`ifconfig | while read _line; do
[[ $_line == "lladdr "$_mac ]] && \
echo ${_lineabove%:*} && break
_lineabove=$_line
done`
I didn't know about vlan though.
Note that the vlan devices need to be excluded. Are there other
circumstances which could confuse this in ifconfig's output?
svlan