LoginSignup
2
2

More than 5 years have passed since last update.

ファイルの一括置換ワンライナー(複数行対応)

Posted at

ソース

find src/ -type f -name '*pp' -print | xargs grep -l DEBUG_LOG | while read cppfile; do;perl -0777 -i -pe 'print s/DEBUG_LOG(.*?);//gs;' $cppfile; done;

利用シーン

下記の様なデバッグログがあったとしてプロダクションなどではログを生成するコストすらも削ぎ落としたい場合

hoge.cpp
DEBUG_LOG << "Debug log, as single line." << std::flush;

DEBUG_LOG 
  << "Debug log" 
  << ", as multiple line."
  << std::flush;
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2