#!/bin/sh ########################################################## # Written Feb 14, 2008 and released under the GNU/GPLv2 ## # by Jeff Schroeder (jeffschroeder@computer.org) # # ########################################################## # # # # # top-open-files - Quickly show the top processes with # # # with the largest number of open files # # # in descending order # # # # # ########################################################## VERSION=$(lsof -v 2>&1 | awk '/ revision:/{print $NF}' | tr -d '.') printf "%7s %15s %5s \n" "NUM" "NAME" "PID" # Older iersions of lsof like in RHEL3 don't support the +c option if [ $VERSION > 469 ]; then lsof +c 15 | awk '{printf("%15s (%s)\n", $1, $2)}' | sort | uniq -c | sort -rn | head else lsof | awk '{printf("%15s (%s)\n", $1, $2)}' | sort | uniq -c | sort -rn | head fi