#!/bin/bash
# /usr/local/bin/findext
# https://crystalfaeries.net/posix/bin/findext
# celeste:crystalfaery FINDFILE 2017-08-02 18:36:01+00:00
# http://www.commandlinefu.com/commands/view/17740/find-where-a-kind-of-file-is-stored>
# output a sorted list of the top directories containing files of the extension specified by the argument
# example: findfile mp3
# example: findfile .mp3
extension=$(echo ${1} | sed 's/^.*\.//') # strip off a possible leading "." or whole filename
nice ionice -c 3 find / -name "*.${extension}" 2>/dev/null | sed "s/[^/]*\.${extension}$//" | uniq -c | sort -g
syntax highlighted by Code2HTML, v. 0.9.1