Skip to content

Instantly share code, notes, and snippets.

@abhi1010
Created November 28, 2018 05:12
Show Gist options
  • Save abhi1010/06c4d55756dc23091556a2ff32fd2c04 to your computer and use it in GitHub Desktop.
Save abhi1010/06c4d55756dc23091556a2ff32fd2c04 to your computer and use it in GitHub Desktop.
multi line replace in bash

How to do a multi-line replace in files

Remember to add a backslash for special keywords like //{

perl -i -p0e 's/namespace gng \{\nnamespace strategy \{/namespace gng::engine::xraider \{/igs' *.h

perl -i -p0e 's/namespace gng \{\nnamespace strategy \{/namespace gng::engine::xraider \{/igs' *.cc


perl -i -p0e 's/\}  \/\/ namespace strategy\n\}  \/\/ namespace gng/}  \/\/ namespace gng::engine::xraider/igs' *.h
perl -i -p0e 's/\}  \/\/ namespace strategy\n\}  \/\/ namespace gng/}  \/\/ namespace gng::engine::xraider/igs' *.cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment