Awk
Pick out the fourth token:
mac=`/sbin/arp -a $ip | awk '{print $4}'`
Separate by = instead of whitespace:
echo "a=b=c" | awk -F= '{print $3}' # selects "c"
Duplicate entries in the passwd file? Compare these:
awk -F: '{print $1}' /etc/group | sort -u | wc -l awk -F: '{print $1}' /etc/group | wc -l