[PLUG] Help needed, he sed

Rich Shepard rshepard at appl-ecosys.com
Sun Nov 10 01:06:58 UTC 2002


  I've missed an important step in modifying a flock of files with sed and
I'd appreciate receiving a correction to my approach. Here's the situation:

  I have a directory with several dozen .cpp files and I want to change an
'include ' line to reflect the name change to a header file. If I run
	sed 's/mtsptype.hpp/prototype.h/g' *.cpp
the change is made to STDOUT, not written to the file. According to the ORA
'sed & awk' book, there's a flag, w, for writing the results. Up to 10 files
can be open, says the book.

  As I've not used sed in a mass production mode before, I don't know if I
can get the results I want (i.e., change all references to the prototype
header -- probably only referenced once per source file -- and write the
changed file back to disk with the same name) if I change the syntax to
	sed 's/mtsptype.hpp/prototype.h/gw' *.cpp

  Is this the way to do it?

TIA,

Rich





More information about the PLUG mailing list