I\'m trying to determine what application is using certain port and get netstat -tlnp | grep
.
This command return the following o
... | awk '{print $7;}'| sed 's/\// /g'
awk + sed:
awk '{print $7}' | sed "s/\// /g"
netstat -tlnp 2>/dev/null | awk '/\.[0-9]:X/ {print $7}' | sed 's/\//\s/g'
where X in the awk bit is the port you're looking at.
Try netstat -p
-p, --program Show the PID and name of the program to which each socket belongs.
Also you can get rid of that "you have to be root" message by redirecting stderr to /dev/null
netstat -tlnp 2>/dev/null | grep ...
Try
ps -p $(lsof -ti tcp:80) o comm=,pid=
or
netstat -tlnp | awk '/:80 */ {split($NF,a,"/"); print a[2],a[1]}'