sourcecode

Tuesday, March 5, 2013

Recursive global replace

 find ./ -type f -exec \
 sed -i 's/\<map\>/unordered_map/g' {} +
under a folder, do an exact match, and recursively replace to a new word.

The motivation was this: I want to upgrade my source code to C++11. To be more efficient, all the old <map> header and usage, which is log(n), should be replaced by the new hash function in <unordered_map>. But there are other names with prefix or postfix "map", which should not be changed.

No comments: