10
rated 0 times
[
10]
[
0]
/ answers: 1 / hits: 3357
/ 1 Year ago, wed, may 24, 2023, 8:24:57
I often do e.g.
sudo netstat -lpn |grep :8088
view the output
tcp6 0 0 :::8088 :::* LISTEN 11189/java
and then
sudo kill -kill 11189
I'd like to have a more convenient command exactly like killatport 8088
that uses the tcp port number as a variable and that I can make as an alias to a pipeline that does what I want, but how do I get the PID from the output and pipe it to the kill command? I suppose I might be able to use awk to get the PID from the output from netstat, but how do I safeguard and make an exact port match so that the input 80 won't match 8080 and likewise? Should I make it a C program instead? Or is there already a small utility like this?
More From » bash