May 2017
Beginner
552 pages
28h 47m
English
The :[0-9a-z]+-> regex for grep extracts the host port portion (:34395-> or :ssh->) from the lsof output. The next grep removes the leading colon and trailing arrow leaving the port number (which is alphanumeric). Multiple connections may occur through the same port and hence, multiple entries of the same port may occur. The output is sorted and passed through uniq to display each port only once.