ambevar-dotfiles/.scripts/lsofstat

22 lines
271 B
Bash
Executable File

#!/bin/sh
if [ "$1" = "-h" ]; then
cat<<EOF
Usage: ${0##*/}
Print number of open files per process.
EOF
exit
fi
LSOFOUT="$(lsof|awk '{print $1}')"
while IFS= read -r i; do
echo -n "$i "
echo "$LSOFOUT" | grep -c "^$i"
done<<EOF
$(echo "$LSOFOUT" | sort -u)
EOF