A Code Monkey's Blog

Use Perl like sed

Recently I wanted to use Perl and Bash to deal with a large number of files. I ended up needing in-line string substitution to create new shell commands. I vaguely had an idea that I should use 'sed' to do the text transform but by any chance I would like to use Perl. I rarely use Perl as one-liner. It turned out that this is the correct way to do so

find . -name "*.java" -print | perl -ne 's/java/java.old/g && print'

Perl Perl