[lug] find command or similar

Kenneth D. Weinert mc at quarter-flash.com
Tue May 13 11:53:45 MDT 2003


On Tue, May 13, 2003 at 11:27:54AM -0600, Ed Hill wrote:
> On Tue, 2003-05-13 at 11:19, Kenneth D. Weinert wrote:
> > Here's a little shell script that should do the trick. I use locate
> > because it's faster, but it could be replaced with:
> > 
> > find / -type f -print
> > 
> > locate \* | while read path;do
> >   file=$(basename $path); 
> >   res=$(echo $file | egrep "[[:alnum:]]{10,15}"); 
> >   if [ ! -z $res ];then 
> >     echo $path;
> >   fi;
> > done
> > 
> > Where I have {10,15} you could put {200,} for your first case and
> > {200.240} for your second.
> > 
> > Note that the [[:alnum;]] expression might not match all filenames -
> > you can do a "man egrep" and look at the regular expression syntax to
> > make it more closely conform to what you might find on your system.
> 
> 
> Not only is:
> 
>   find . -name '*' -depth -printf "%f\n" | egrep '.{201,}'
> 
> a "one-liner" but it overcomes the pattern-matching problems mentioned
> above.
> 
> Heh, I win.  ;-)

Sort of - replace the [[:alnum:]] in mine with . (and I should have
thought of that) and I turn back into the winner because you know
*where* the file is, not just its name.

Of course, that wasn't part of the spec, so I guess it's a tie :)

-- 
/~\ The ASCII        Ken Weinert   mc at quarter-flash.com 
\ / Ribbon Campaign  303-452-6603 (V) 303-705-4258 (F)
 X  Against HTML     GnuPG: 9274F1CE  GnuPG available at http://www.gnupg.org/
/ \ Email!           1D87 3720 BB77 4489 A928  79D6 F8EC DD76 9274 F1CE
Most people are really scared of werewolves but I bet if
you saw one crying because the other wolves had made fun of 
him, you would probably feel sorry for him and try to pet
him. That was my first mistake.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20030513/570642e7/attachment.pgp>


More information about the LUG mailing list