How do I grep something and prevent the phrase appearing in the results?
I am trying to get only the MAC address from multiple systems and want only the MAC address in the results.
ipmitool lan print | grep "MAC Address : "
# => MAC Address : aa:bb:cc:dd:ee:ff
I got as far using google as trying is by adding -oP
and \K\w+
but for some reason it only get's the first 2 digits of the MAC:
ipmitool lan print | grep -oP "MAC Address : \K\w+"
# => aa
I understand the -o
will only show the matched text which is why the MAC address is not being shown up and -P
used with \K
will prevent everything in-between from showing up but not sure what exactly to put after \w+
to make the rest of the MAC address show up.