[mdlug] How to find file name length?

Raymond McLaughlin driveray at ameritech.net
Wed Sep 26 03:51:52 EDT 2007


Paul wrote:

>>
> Well, this is almost perverse (and probably slow), but
> this invokation will tell you all the files greater than 99
> characters long (in theory):
> 
> #>  find / -type f -exec bash -c 'echo "$(basename "{}" | wc -c) {}" ' \;
> 	| egrep '^1[0-9]{2}'

> Paul
> set at pobox.com


Actually "egrep '^1[0-9]{2}'" only filters for numbers 100-199. A more
general construct: "egrep '[0-9]{3,}'" will find all numbers of three or
more digits. Don't some filesystems allow for filenames of 255 or more
characters?

Also, thanks for making me look at man egrep to see what {2} did.
Another tool for my belt.

Ray




More information about the mdlug mailing list