Skip to content

Instantly share code, notes, and snippets.

@eiiches
Created February 27, 2011 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiiches/845995 to your computer and use it in GitHub Desktop.
Save eiiches/845995 to your computer and use it in GitHub Desktop.
Search hosts available for SSH.
#!/bin/bash
grep 'ant\|bee\|cat\|dog\|emu' /etc/hosts | while read ip host; do
nc -w 1 -z "$ip" 22 > /dev/null && echo "$host" &
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment