1

I'm using sed and grep to search and replace boost::shared_ptr with std::shared_ptr. How do I keep egrep out of .svn. Its leading to local corruptions:

Transmitting file data .svn: E155017: Commit failed (details follow):
svn: E155017: Working copy text base is corrupt
svn: E200014: Checksum mismatch for text base of '/home/jeffrey/owasp-esapi-cplusplus/doc/html/_codec_8cpp_source.html':
   expected:  09ead67f10a06a392ec41455179da560
     actual:  310ceca1a9c721b40db494f62854d2df

Jeff

Community
  • 1
  • 1
jww
  • 90,984
  • 81
  • 374
  • 818

2 Answers2

4

I recommend you to use ack instead of grep to search files. It takes the same basic options as grep.

It will skip .svn, .git... dirs & binaries by default.

Example :

ack -rl --print0 "pattern" . | xargs -0 -l sed -i 's/pattern/other_pattern/g'

So finally :

ack -rl --print0 "boost::shared_ptr" . |
    xargs -0 -l sed -i 's/boost::shared_ptr/std::shared_ptr/g'
Gilles Quenot
  • 154,891
  • 35
  • 213
  • 206
2

Try find with xargs

find /path/to/basedir -name .svn -prune -o -iname '*.h' -print0 , -iname '*.cpp' -print0 | xargs -0 sed -i 's/boost::shared_ptr/std::shared_ptr/g'
Olaf Dietsche
  • 69,448
  • 7
  • 95
  • 188