I want to delete all files in the current directory and sub directories whose file name is more than a particular length.
Is there an easy way of doing this from bash?
You have already provided a
This regex matches five trailing characters that do not contain a slash (i.e. the filename is longer than five chars).
The Bash loop you provided will generally work, but it probably does not scale with thousands of files and may break with special filenames.
An alternative that is similar in efficiency, but may provide more flexibility (replace
As you will rarely find files with
You can use
Alternatively, you can do everything from