Thursday, July 3, 2008

counting lines in Unix

Andrzej tracked down those open files with the following command. What's cool is that he counts how many instances a record occurs with 'uniq', and he uses 'sort -n':


lsof | grep -e '^java.* REG ' | grep ' dtstage ' | awk '{print $9}' | sort | uniq -d -c | sort -n


Here's a quick demo of 'sort -n'... see how the results are different if you remove the '-n':


echo " 1\n.5" | sort -n

No comments: