Skip to content

Instantly share code, notes, and snippets.

@maxheadroom
Last active August 29, 2015 14:11
Show Gist options
  • Save maxheadroom/d71da538b0f5c27f3d4e to your computer and use it in GitHub Desktop.
Save maxheadroom/d71da538b0f5c27f3d4e to your computer and use it in GitHub Desktop.
Find processes with more than X instances
# usage: ps -e | awf -f find_process_count.awk
# output
{
limit = 5
# turn the process names into lowercase
$4 = tolower($4) # remove case distinctions
# count occurances of $4
freq[$4]++
}
END {
for (word in freq)
# print if above limit
if (freq[word] > limit ) printf "%s\t\t\t\t%d\n", word, freq[word]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment