#! /bin/bash
# usage e.g. testping 192.168.1
if [ $# = 0 ]; then
	echo "please give me the net to test e.g. 192.168.1"
else
  HOSTS=$'\nAvailable Hosts:'
  x=256
  while [ $x -gt 0 ]
  do
    x=$(( $x - 1 )) 	
    TIME=`(ping -c 1 $1.$x 2> /dev/null | sed -n "s/.*\/\([0-9]\{1,4\}\.[0-9]\{3\}\)\/.*\/.*/\1/p") & sleep "0.1" ; kill %+`
    if [ "$TIME" == "" ] ; then
        [ "$opt_q" = 1  ] || echo -n "." >&2
    else
        [ "$opt_q" = 1  ] || echo -e "\nHost \"$1.$x\" respondet in $TIME ms"
	HOSTS=$HOSTS$'\n'$1.$x
    fi
  done
echo "done"
echo "$HOSTS"
fi
