I have this command which works well to give me a list of ip address, MAC address, and Mac Vendor
sudo nmap -sn 192.168.0.0/24 | awk '/Nmap scan report for/{printf $5;}/MAC Address:/{print " "substr($0, index($0,$3)) }' | sort
All I want to do is to add a comma as a delimeter between each of the three fields and sort the ip address column by the last octet of the ip address. By changing the command as follows I can get a comma between 1rst and 2nd column and can sort by ip address. Now I just need a comma between 2nd and 3rd column. How to add the last comma?
sudo nmap -sn 192.168.0.0/24 | awk '/Nmap scan report for/{printf $5;}/MAC Address:/{print ","substr($0, index($0,$3)) }' | sort -t . -k 4,4n