Skip to content

Instantly share code, notes, and snippets.

@caorong
Created May 13, 2016 15:37
Show Gist options
  • Save caorong/78a17a9b4485bf02d21698ea6903bef7 to your computer and use it in GitHub Desktop.
Save caorong/78a17a9b4485bf02d21698ea6903bef7 to your computer and use it in GitHub Desktop.
find free port
#!/bin/bash
i=8031;
for (( ; ; ))
do
_="$((i++))"
# echo "Number: $((i++))"
#netstat -apn|grep 8001|wc |awk '{print $1}'
X=$(netstat -apn|grep $i |wc|awk '{print $1}')
echo $X
if (( x < 1 )); then
echo use "$i"
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment