[mdlug] How to find file name length?

Aaron Kulkis akulkis3 at hotpop.com
Wed Sep 26 16:02:59 EDT 2007


Michael Corral wrote:
> 2007-09-26, Monsieur Aaron Kulkis a ecrit:
>> Adam Tauno Williams wrote:
>>>>> So the question is: Is there a way to find all files with a name length of
>>>>> greater than 103 character?
>>> find tmp -name "???????????????*" will find all the files with a file
>>> name length of 15 or more in the directory named "tmp".  Crude, but it
>>> works.
>>>
>> Actually, it is a perfectly elegant solution.
>
> Not when it has to check for 104 or more characters it isn't. :)


Ok, let's say it comes across a 5-char name.

The match FAILS on the 6th character, and the wildcard
matching algorithm promptly returns.

On the other hand, EVERY solution *MUST* check for 104 or
more characters, and that means COUNTING the characters,
(traversing the string with a pointer and incrementing
the pointer each time until the pointer hits a 0x00 ("null").

The wildcard matching system conducts two string
traversals in parallel, and as soon as a non-match
is found, it returns the value indicating "no match"
> In some places a "solution" like that will get you shot, and
> rightly so. ;)

Only if the person dispensing justice doesn't understand
how the matching implementation is actually behaves.

Since a ? mark matches ANY character, the "match" testing
is merely one of testing for existance -- essentially a
"degenerate case" in which any character tested is a match,
because it exists.

So, on 103-char or less names, what ACTUALLY causes the
match to fail is the fact that the name ends, but the
pattern string still has not yet been fulfilled becaus
of oustanding mandatory matches (the next ?, or the final *).

>
> Michael
> _______________________________________________
> mdlug mailing list
> mdlug at mdlug.org
> http://mdlug.org/mailman/listinfo/mdlug
>






More information about the mdlug mailing list