grep -Hrl DataLogger /testFolder/ | xargs sed /,$/{N -e"s|DataLogger::copyStringLength(\(dl.[a-zA-Z0-9]\+\)..\(.\+\)(.c_str()\)\+\(,\s*.*;)|IDataLogger::copyString(\2, \1);|g"}
I'm using the above script to change a method call from DataLogger::copyStringLength(dest, source, length)
to IDataLogger::copyString(source, dest)
.
The script above overall seems to do as I want it to, and is replacing things regardless of newlines in the method call. But as it is now, I am only printing to the console, rather than in-place in the files. I've tried placing the -i option in several places in the sed call, and it always gives back an error.
Any feedback would be appreciated.
For those curious as to why and where the line breaks appear, there are 3 different formats for this method (depending on the length of variable names)
copyStringLength(varA, varB, varC);
copyStringLength(varA, varB,
varC);
copyStringLength(varA,
varB,
varC);