Created
April 2, 2020 13:49
-
-
Save gavvvr/0afa07bc52d8bef61c6d2ef807bc0579 to your computer and use it in GitHub Desktop.
netstat with full command running an associated process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
netstat -antp 2>&1 | sort -k7,7 -k 6,6| { | |
while IFS= read -r line | |
do p="$(sed -En 's/^.*( [0-9]+)\/[^ ]*.*/\1/gp'<<<"$line")"; | |
[ "$p" == "" ] || p=" ## $(ps -p $p -o cmd=)"; | |
echo "$line"$p; | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment