Created
January 2, 2018 18:44
-
-
Save ahmed-musallam/013cc1f20e942f6e9fe196a131059faa to your computer and use it in GitHub Desktop.
See how many files each pid is opening in macOs
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
# based on https://www.reddit.com/r/osx/comments/3ewn93/too_many_open_files_in_system_what_is_causing_this/ctj765h/ | |
# will print a list of comma seperated enties, each entry is in this format: <PID name>, <PID>, <Files open> | |
sudo lsof -n | perl -pe '$x = <>; while(<>) { ($cmd, $pid, $rest) = split(/\s+/); $cmds{$pid} = $cmd; $pids{$pid}++;} while( ($key, $val) = each %pids) { $pidName=$cmds{$key}; printf "$pidName,$key,$val \n" } ;' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment