rob@budapest:~$ find2perl . -type f -exec perl -pi.bak -e 's/old/new/g +' {} \; #!/usr/bin/perl-5.005 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if $running_under_some_shell; require "find.pl"; # Traverse desired filesystems &find('.'); exit; sub wanted { (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && -f _ && &exec(0, 'perl','-pi.bak','-e','s/old/new/g','{}'); } sub exec { local($ok, @cmd) = @_; foreach $word (@cmd) { $word =~ s#{}#$name#g; } if ($ok) { local($old) = select(STDOUT); $| = 1; print "@cmd"; select($old); return 0 unless <STDIN> =~ /^y/; } chdir $cwd; # sigh system @cmd; chdir $dir; return !$?; }
In reply to Re: Need one-liner to s///g in all sub-dirs
by rob_au
in thread Need one-liner to s///g in all sub-dirs
by dvergin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |