in reply to Re: file lookup
in thread file lookup
If you insist on perl, you have find2perl,
Here is the output of find2perl
$ find2perl /path/to/dir -name "*.txt" -exec /some/script {} #! /usr/local/bin/perl -w eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' if 0; #$running_under_some_shell use strict; use File::Find (); # Set the variable $File::Find::dont_use_nlink if you're using AFS, # since AFS cheats. # for the convenience of &wanted calls, including -eval statements: use vars qw/*name *dir *prune/; *name = *File::Find::name; *dir = *File::Find::dir; *prune = *File::Find::prune; # Traverse desired filesystems File::Find::find({wanted => \&wanted}, '/path/to/dir'); exit; sub wanted { /^.*\.txt\z/s && &doexec(0, '/some/script','{}'); } BEGIN { require Cwd; my $cwd = Cwd::cwd(); } sub doexec { my $ok = shift; for my $word (@_) { $word =~ s#{}#$name#g } if ($ok) { my $old = select(STDOUT); $| = 1; print "@_"; select($old); return 0 unless <STDIN> =~ /^y/; } chdir $cwd; #sigh system @_; chdir $File::Find::dir; return !$?; }
-T
use perl; use strict;
|
|---|