in reply to Re^2: One-line shell script for find and replace
in thread One-line shell script for find and replace
Close, but you can do better.
perl -MFile::Find -pi -e'BEGIN { find( sub { push @ARGV, $File::Find:: +name if /\.txt\z/i }, "." ) } s/find/replace/'
With File::Find::Rule you write it more nicely.
perl -MFile::Find::Rule -pi -e'BEGIN { @ARGV = File::Find::Rule->name( + "*.txt" )->in( "." ) } s/find/replace/'
But in practice I’d use find -print0 | xargs -0 for this. Way too much work to do it in Perl.
Makeshifts last the longest.
|
|---|