#!/bin/bash host=10.10.10.5 for port in {1..65535}; do timeout .1 bash -c "echo >/dev/tcp/$host/$port" && echo "port $port is open" done echo "Done"