How to find files with filenames that are too long

February 19, 2014 regular expressions shell script

Here’s a neat regular expression trick that you can use to find pathnames longer than a certain length, say, 20 characters:

find -E . -regex '.{20,}'

If you only need filenames that are too long (without the path), the regex is a bit more complicated:

find -E . -regex '.*[^/]{20,}$'

Buy me a coffee Liked the post? Treat me to a coffee