Advertisement
teuk

listen_tcp_ports_lsof.sh

Jan 7th, 2017
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.25 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # listen_tcp_ports_lsof.sh
  4.  
  5. for port in $(ss -ltn | tail -n $[$(ss -ltn | wc -l)-1] | awk '{print $4}'| sed -e 's/^.*://' | sort -n)
  6.  do
  7.     (lsof -i:$port | grep LISTEN) | while read line
  8.      do
  9.         echo "$port $line"
  10.      done
  11.  done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement