Skip to content

Instantly share code, notes, and snippets.

@estahn
Last active August 29, 2015 14:21
Show Gist options
  • Save estahn/a901c5aea86525ff1766 to your computer and use it in GitHub Desktop.
Save estahn/a901c5aea86525ff1766 to your computer and use it in GitHub Desktop.
Number of open files per process
#!/bin/sh
processes=$(lsof | cut -f1 -d" " | sort | uniq | xargs -n1 -I% sh -c 'echo % `pidof % | sed -e "s/ /,/g"`' | cut -d" " -f1 -s)
for process in $processes; do
echo $process $(pidof $process | sed -e "s/ /,/g" | xargs -I% -n1 sh -c 'lsof -a -p % | wc -l')
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment