Skip to content

Instantly share code, notes, and snippets.

@l3acucm
Created January 1, 2023 10:24
Show Gist options
  • Select an option

  • Save l3acucm/1395a61749f47d2b794bfba8c3c830f8 to your computer and use it in GitHub Desktop.

Select an option

Save l3acucm/1395a61749f47d2b794bfba8c3c830f8 to your computer and use it in GitHub Desktop.
kill port on macos
#!/bin/bash
if [ -z "$1" ]
then
echo "Port not specified"
else
greparray=$(lsof -i tcp:$1 | grep -Eo "\s(\d{5})\s")
for pid in $greparray
do
kill -9 $pid
echo $pid
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment