Files
dotfiles/local/bin/x-open-ports
Ismo Vuorinen bb3f4a8f6c Many updates and improvements
- yamllint
- shfmt config
- fix Go bin path
- fix git credentials config
- add nvm default packages
- updated Brewfile
2023-03-28 15:27:44 +03:00

22 lines
643 B
Bash
Executable File

#!/usr/bin/env bash
#
# List open (listened) ports, without the crud that
# usually comes with `lsof -i`
#
# Modified by: Ismo Vuorinen <https://github.com/ivuorinen> 2020
# Originally from: https://www.commandlinefu.com/commands/view/8951
# Original author: https://www.commandlinefu.com/commands/by/wickedcpj
#
echo 'User: Command: PID: Port:'
echo '========================================================='
lsof -i 4 -P -n +c 0 \
| grep -i 'listen' \
| awk '{print $3, $1, $2, $9}' \
| sed 's/ [a-z0-9\.\*]*:/ /' \
| sort -k 3 -n \
| xargs printf '%-15s %-25s %-8s %-5s\n' \
| uniq
echo ""