Reputation: 99
I am looking for a Lua replacement for the following bash script:
MAC="d4:be:d9:3a:78:88"
IP=`grep $MAC /tmp/dhcp.leases | awk {'print $3'}`
echo $IP
/tmp/dhcp.leases looks like:
1497518739 d4:be:d9:3a:78:88 192.168.96.180 DESKTOP-2VECMJ7 01:d4:be:d9:3a:78:88
Upvotes: 0
Views: 158
Reputation: 72312
After reading the file into a Lua string, extracting the IP address is simple:
function extract(text,mac)
return text:match(" "..mac.." (.-) ")
end
Upvotes: 1