3 ms·grep isn't necessary at all here: lsof -s TCP:LISTEN -i :$portby addingnumbers 3y agogrep isn't necessary at all here: lsof -s TCP:LISTEN -i :$porthdjjhhvvhga 3y agoYou could also add the -t option for direct piping to kill.