in reply to Replacing one string within a file with another string

perl -i.bak -ne 's/Name/FullName/g; print' *.INF

See File::Find for the ability to scan an entire tree.

If I were on a *NIX box, I would use:
perl -i.bak -ne 's/Name/FullName/g; print' `find . -name *.INF`
find in backticks to traverse the tree.

It's not cross-platform like tye's solution below, but I'm almost as big a Linux bigot as I am a Perl bigot...

:-)

Russ
Brainbench 'Most Valuable Professional' for Perl

  • Comment on RE: Replacing one string within a file with another string

Replies are listed 'Best First'.
RE: RE: Replacing one string within a file with another string
by tye (Sage) on Aug 18, 2000 at 03:38 UTC

    But don't you wish there was a better way to mix the two?

    perl -i.bak -pMFile::find -e 'BEGIN{find(sub{push@ARGV,$File::find::na +me if /[.]inf$/i},".")}s/Name/FullName/g'

    just seems like too much work!.

            - tye (but my friends call me "Tye")
      Nice use of -M, BEGIN{} and @ARGV.

      Too much work? Perhaps, but nice, anyway!

      Russ
      Brainbench 'Most Valuable Professional' for Perl