1

I'm trying to know a way to show only MAC address from every NIC I have on any running virtual machine:

So far I have this:

ipcopv2
-----------------------------------------------
Groups:          /Infraestructura
State:           powered off (since 2018-03-16T13:30:56.389000000)
NIC 1:           MAC: 080027D40320, Attachment: Bridged Interface 'eth1.15', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 2:           MAC: 080027660656, Attachment: Bridged Interface 'eth1', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 3:           MAC: 0800270D3D9E, Attachment: Bridged Interface 'eth0', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
Capture screens:    0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

I want to have this:

ipcopv2
-----------------------------------------------
Groups:          /Infraestructura
State:           powered off (since 2018-03-16T13:30:56.389000000)
NIC 1:           MAC: 080027D40320, Attachment: Bridged Interface 'eth1.15', Cable connected: on
NIC 2:           MAC: 080027660656, Attachment: Bridged Interface 'eth1', Cable connected: on
NIC 3:           MAC: 0800270D3D9E, Attachment: Bridged Interface 'eth0', Cable connected: on
Capture screens:    0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

How to accomplish this? I want to understand how to read the info and only show that part using bash.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
maniat1k
  • 1,495
  • 4
  • 25
  • 40

1 Answers1

3

This seems to do the trick:

$ ip link | awk '/link/ { print $2 }'
00:00:00:00:00:00
00:20:78:1c:xx:yy
00:1d:92:67:xx:yy
DopeGhoti
  • 73,792
  • 8
  • 97
  • 133
  • great! I did this: `/usr/bin/VBoxManage showvminfo $i | grep 'MAC' | awk '/MAC/ { print $4 }'` thanks! – maniat1k Mar 27 '18 at 20:53