#!/bin/bash if [ ! $1 ]; then echo "Please give a port" exit elif [ $2 ]; then echo "Only 1 argument(port) need to be given" exit elif $(kill $(lsof -t -i :$1) 2> /dev/null); then echo "Killed $(ps -p $(lsof -t -i :$1) -o comm=) with SIGTERM" else echo "No process in port" fi