How to list all file extensions within a directory

By Lad

Here’s a simple command to list all file extensions (recursively) within the current directory
(thanks to this forum posting

find . -type f | sed -e 's/.*\.//' | sort | uniq -c | sort -rn

When you have, for example, a large codebase with lots of files that have no extension (e.g., Makefile, README, etc.), the above lists them with their full path.

Here’s a modified version of this to remove any /path/to/file/ and so just list those files too:

find . -type f | sed -e 's/.*\.//' | sed -e 's/.*\///' | sort | uniq

Leave a Reply