I am using git bash on Windows.
I have a large set (thousands) of c/c++ files with autogenerated headers that I want to replace. My plan is first to strip the headers then apply new ones.
These headers follow the pattern:
/************************************************************************************ ///_|
File: $Id: //perforcedepot/path/filename.ext#1 $
LEGAL NOTICE: COPYRIGHT YYYY by COMPANY NAME, All Rights Reserved
*************************************************************************************/ //|_/
I experimented a bit and came up with this:
sed '//*********/,// //|_//d' filename.ext
Seems good enough, but I’m wondering if there is a more elegant way to do the match?
Also, I tested it with find as so:
find . -iregex '.*.(h|c|hpp|cpp)$' -exec sed '//*********/,// //|_//d' {} ;
Seems to be picking up the correct files, based on a small test sample.
My plan is now to add “-i” to make sed overwrite the files.
But I feel like I made this harder on myself than it needed to be. So my question is: Did I come by the right approach here? Is there an easier solution?