#!/bin/bash # Which process is using the port? # Usage: which-port # # Example: # $ which-port 3000 # -+- 87504 andrew node /Users/a/Projects/thing/node_modules/.bin/vite # \--- 87573 andrew /Users/a/Projects/personal/thing/node_modules/esbuild-darwin-64/bin/esbuild --service=0.14.38 --ping if [ $# -eq 0 ] then echo "No arguments supplied: specify port" exit 1 fi pid=`lsof -i :$1 -t` if [ -z "$pid" ] then echo "No pid for port $1" exit 1 fi pstree $pid