Grrrrrrr ran into my inotify problem again. So I was wondering how I can see which program has files opened and how many. Well as with everything under Linux it is possible with a few “simple” commands. Try the following command for fun and entertainment.
$ lsof | awk ‘{print $1}’ | sort | uniq -c | sort -g -k 1 | tail
- lsof: lists the open files
- awk: takes the first column of the output
- sort: yep it sorts the output
- uniq: counts all the same value
- sort: do you want me to repeat it? a little clarification is necessary -k tells which column to sort on and -g makes sure that the contents is treated like a number
- tail: gives the last ten entries