shellは、ネットワークセグメントのIPとmacの対応関係を統計するファイルmacに保存する.txt
#!/bin/bash
#function: Count the relationship between ip and mac in a C subnet
#created by comk at Mar.12.2016
quitScript() {
echo "User Interrupt ,Quit..."
}
trap 'quitScript; exit 5' SIGINT #### support ctrl+c interrupt
read -p " ( 192.168.0.0):" string
a=`echo $string|cut -d"." -f1-3`
for i in {1..254};do
ping -c 1 $a.$i
done
exec arp -a | cut -d" " -f2,4 | tr -s [\(\)] [" "" "] > mac.txt