Skip to content

Instantly share code, notes, and snippets.

@jimlambie
Created June 27, 2018 22:27
Show Gist options
  • Save jimlambie/6a2a6a89481e8e5b518d7c84caf7bfc5 to your computer and use it in GitHub Desktop.
Save jimlambie/6a2a6a89481e8e5b518d7c84caf7bfc5 to your computer and use it in GitHub Desktop.
BASE_PORT=3001
INCREMENT=1
port=$BASE_PORT
isfree=$(netstat -taln | grep $port)
while [[ -n "$isfree" ]]; do
port=$[port+INCREMENT]
isfree=$(netstat -taln | grep $port)
done
echo "$port"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment