x-open-ports helper script

This commit is contained in:
Ismo Vuorinen
2022-09-21 15:28:10 +03:00
parent 4edca57eea
commit fd6f59706b

20
local/bin/x-open-ports Executable file
View File

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