Skip to content

Instantly share code, notes, and snippets.

@sorah
Last active August 29, 2015 14:14
Show Gist options
  • Save sorah/a83dd2f9fcf90a211019 to your computer and use it in GitHub Desktop.
Save sorah/a83dd2f9fcf90a211019 to your computer and use it in GitHub Desktop.
(lsof -iTCP -s TCP:LISTEN -n; lsof -d cwd) | ruby -e '$stdin.readlines.map {|_| __ = _.chomp.sub(/ \(LISTEN\)$/,"(LISTEN)").split; [__[1], __[0], __[-1]] }.group_by(&:first).each {|pid, val| vs = val.map(&:last); name = val.first[1]; next if vs.grep(/\(LISTEN\)/).empty?; puts "#{name}(#{pid}): #{vs}" }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment