in reply to How to search recursively and return specific patterns
Update: Thanks to andreas1234567 for suggesting I add a -f test to avoid printing non-files. I guess, it's unlikely to find anything other than a file that ends ".mp3" or ".rm", but best to be on the safe side!#!/usr/bin/perl use strict; use File::Find; my @dirs = @ARGV or die "Please supply a valid directory to search"; find(\&wanted, @dirs); sub wanted{ if(-f && m/\.(mp3|rm)$/){ print "$File::Find::name\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to search recursively and return specific patterns
by dilip_val (Acolyte) on Aug 24, 2007 at 14:34 UTC | |
by chrism01 (Friar) on Aug 24, 2007 at 14:47 UTC | |
by dilip_val (Acolyte) on Aug 24, 2007 at 15:33 UTC |