Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'one line perl version with Approximate matching' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
one line perl version with Approximate matching
Authored by: SOX on Apr 10, '07 06:55:31PM
New and improved perl version.

Features:

  1. first parameter is now the origin directory for the search, follow with phrase
  2. search is liberal, matching approximate forms of the phrase: that is it allows up to 20 characters to be inserted between the words of the phrase and it will still match.
  3. this 20 character grace means it will match phrases around carriage returns, tabs, and many kinds of HTML markups
  4. no need to "quote" the phrase unless it contains chars needing shell escapes
  5. phrase can contain special characters

perl -e '($f,@A) = map { quotemeta } @ARGV;  open FH, "mdfind -onlyin $f \"@A\" |"; $A = join ".{1,20}",@A; while ($r=<FH>) {  chomp ($r) ; $s=quotemeta($r); @x = grep {m/$A/} `mdimport -nfd2 $s \&> /tmp/crap ; cat /tmp/crap`; print "$r\n" if @x>0}   ' ./ centimeter measure


[ Reply to This | # ]