SyntaxFix
Write A Post
Hire A Developer
Questions
To script this:
pid=$(lsof -ti tcp:8080) if [[ $pid ]]; then kill -9 $pid fi
The -t argument makes the output of lsof "terse" which means that it only returns the PID.
-t