linuxterminalraspberry-piarp

Matching multiple MAC address in arp-scan's output


I'm using this sudo arp-scan --localnet | awk '/b8:27:/ { print $1 }' to find Raspberry pis on my network based on a partial Mac address and I was wondering how I can display multiple awk print results using one single line without repeating the same command?

Raspberry pi's use the following ranges:

dc:a6:
b8:27:
e4:5f:
28:cd:c1:

This works, but only with one single Mac.

sudo arp-scan --localnet | awk '/b8:27:/ { print $1 }'


Solution

  • Just add them all to the regex (at least that's what I think you were asking for, your question isn't very well worded) - the pipe | functions as an or:

    sudo arp-scan --localnet | awk '/b8:27:|dc:a6:|e4:5f:|28:cd:c1:/ { print $1 }'