I am writing a #!bin/bash
shell script to automate MAC spoofing. In the script that I have written I make the outputs of ifconfig -a | grep HWaddr
equivalent to two different variables. The command ifconfig -a | grep HWaddr
returns
eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
and
wlan0 Link uncap: Ethernet HWaddr 00:00:00:00:00:00
but I want the command to return just the MAC address for wlan0
.
Try:
By specifying
wlan0
as the first argument toifconfig
, you are telling it you only want information about that particular interface, so you should only get a single line returned.The
grep
command then searches for a MAC address in the output and prints only the portion of theifconfig
output which matches.OR
Just for your script you can try follwong:
OSX