Skip to content

Instantly share code, notes, and snippets.

@Voronenko
Created April 24, 2015 10:50
Show Gist options
  • Save Voronenko/8ccd3226af34a447e4ec to your computer and use it in GitHub Desktop.
Save Voronenko/8ccd3226af34a447e4ec to your computer and use it in GitHub Desktop.
Find first unused port above ...
#!/bin/bash
ss -tln |
awk 'NR > 1{gsub(/.*:/,"",$4); print $4}' |
sort -un |
awk -v n=3000 '$0 < n {next}; $0 == n {n++; next}; {exit}; END {print n}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment