Skip to content

Instantly share code, notes, and snippets.

@bepcyc
Created June 7, 2016 15:30
Show Gist options
  • Save bepcyc/64567b81c42db72f69b47dd6521e8931 to your computer and use it in GitHub Desktop.
Save bepcyc/64567b81c42db72f69b47dd6521e8931 to your computer and use it in GitHub Desktop.
To list immediate subdirectories containing greater than $NUM files.
# https://superuser.com/questions/617050/find-directories-containing-a-certain-number-of-files/946283#946283
# To list immediate subdirectories containing greater than $NUM files.
# if doesn't work try set $NUM explicitly
find -type f -printf '%h\0' | awk -v num="$NUM" 'BEGIN{RS="\0"} {array[$0]++} END{for (line in array) if (array[line]>num) printf "%s\n", line}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment