in reply to Re: Quick file search
in thread Quick file search

The lack of unix "find" utility is enormous but "tree" filtered results solve to some extent this problem:
# rough comparison D:\music>perl -MFile::Find -e "find(sub{$File::Find::name}, '.');print + time-$^T" 6 D:\music>perl -e "`tree /f /a`;print time-$^T" 1
Where "music" contains 5547 files (without the directory inodes).


Replies are listed 'Best First'.
Re^3: Quick file search
by graff (Chancellor) on Jan 05, 2006 at 05:46 UTC
    The lack of unix "find" utility is enormous

    I'm wondering what you mean by that. There are windows ports of "find" available (google "unix tools for windows"); the ATT Research Labs version and the cygwin version are both authentically "unix-like" (or maybe "gnu-ish" is the better term).

    "tree" filtered results solve to some extent this problem

    Oh yes. That seems consistent with what I've seen in the unix domain -- about a 5- or 6-to-1 speed ratio comparing File::Find to "find". For really big directory trees, that multiplier becomes devastatingly significant.

      One thing to note is that you need to put the Cygwin before Windows in the PATH for this to work, since there already is a "find" (although it's really a rather weak "grep") on the system.

      /J

      No need for tool from the "outside" world, maybe just:
      my $search_what = shift || die "no search criteria provided\n"; my $search_where = shift; my $file = qr/\|(?!\+\S{3})(\s.*?)$argv/i; my $clean = qr/^\W+(.+?)\W+$/; $dir = -d $dir ? $dir : '.'; for(`tree /a /f $search_where`){ /(\\|\+)-{3}/ and $dir= $_ and next; if (/$search_what/) { s/$clean/$1/ for $_, $dir; $dir ? print "dir: $dir$/","file: $_$/$/" : print "dir: . $/","file: $_$/$/"; } }