Skip to content

Instantly share code, notes, and snippets.

@b4ldr
Last active August 29, 2015 14:05
Show Gist options
  • Save b4ldr/a648d861cb4ad9e002c8 to your computer and use it in GitHub Desktop.
Save b4ldr/a648d861cb4ad9e002c8 to your computer and use it in GitHub Desktop.
Ugly one liner
for i in /proc/*/fd/*
do
SOCKET_INODE=$(stat -c %N ${i} 2>/dev/null | awk -F\: '/socket:\[[0-9]+\]/ {gsub(/[\[\]]/, "", $NF);print $NF}')
[ "${SOCKET_INODE%?}" == "${INODE}" ] && awk -F\/ '{print $3}'<<< ${i}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment