Automatic Hosts File from NetBIOS Names

Ever wondered how Windows can scan for computers on your network and address them only on their host names?
My autohosts script reads NetBIOS names from your network via nbtscan and adds the hosts to the /etc/hosts file via hosts-manager.

#!/bin/bash
 
RANGE="192.168.0.1/16"
if [ $# -ne 0 ]
then
	RANGE=$@
fi
HOST=""
IP=""
LIST=$(nbtscan -q $RANGE | grep "<server>" | sed -r "s/([^\ ]*)\ *([^\ ]*)*.*/\1xxx\2/")
for LINE in $LIST 
do 
MYLINE=$( echo $LINE | sed -r "s/([^\ ]*)xxx([^\ ]*)*.*/\2 \1/" )
echo "Processing line:  \"$MYLINE\"" 
hosts-manager -a $MYLINE
done