in reply to Re: Searching and Replacing file content within directory
in thread Searching and Replacing file content within directory

I love perl yet often I'll see an issue like this and think 'replace that with a small shell script' or in this case do it all with sed. Glad I'm not the only one. :)
  • Comment on Re^2: Searching and Replacing file content within directory

Replies are listed 'Best First'.
Re^3: Searching and Replacing file content within directory
by tod222 (Pilgrim) on Nov 12, 2010 at 19:49 UTC

    sed? I prefer to stick with perl. Here's a 1-liner to search and replace:

    perl -i -wpe 's/INPUT_TXT/OUTPUT_TXT/g' file1 [... fileN]

    See the perlrun docs for info on using -i.

    Use find if needed to generate the list of files, and pipe its output to Perl via xargs.