Hendra Saputra bio photo

Hendra Saputra

Insatiable knowledge seeker, code monkey, movie addict.

Email Twitter Facebook Google+ Instagram Tumblr Github Flickr

Here’s an awk function I keep using to find out how many open files a username open on a unix system. You should replace ‘oracle’ below with the username you want to check

lsof | awk '/oracle/ {pidct[$2]++;pidname[$2]=$2;procname[$2]=$1} END {for (i in pidname) {printf ("%s %s %dn",procname[i],pidname[i],pidct[i]);}}' | tr -s " " | sort -t " " -n -r -k 3,3