Skip to content

Instantly share code, notes, and snippets.

@gdhaworth
Last active December 24, 2015 16:28
Show Gist options
  • Save gdhaworth/6827793 to your computer and use it in GitHub Desktop.
Save gdhaworth/6827793 to your computer and use it in GitHub Desktop.
Count processes using files inside a directory, going only 3 subdirectories deep. A lil crazy, I know.
watch -n 1 "lsof -F pan /mnt/gentoo 2> /dev/null | grep -Ev '^p' | sed -r '/a./{N;s/^a(.)\nn/\1/}' | cut -d / -f 1,5-8 | grep -Ev '^\s*$' | cut -c 1,3- --output-delimiter=' ' | sort | uniq -c | sed -r 's/ ([0-9]) /0\1 /g' | sort -r"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment