[mdlug] How to find file name length?

Paul set at pobox.com
Thu Sep 27 00:58:35 EDT 2007


Raymond McLaughlin <driveray at ameritech.net>, on Wed Sep 26, 2007 [03:51:52 AM] said:
> 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

	Hi;

#> echo 1095 | egrep '^1[0-9]{2}'
1095

	ie. it doesnt have to pattern match the whole number, just
the first 3 digits. This says 3 digits starting with 1 at the begining
of the line, which is a subset of any potentially larger number.

Paul
set at pobox.com



More information about the mdlug mailing list