Created
February 4, 2014 22:42
-
-
Save rossta/8813895 to your computer and use it in GitHub Desktop.
Find and replace in directory on the shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # example: replacing :mocha with :rspec as mock framework | |
| find . -name '*_spec.rb' -exec sed -i.old -e 's/returns/and_return/' {} \; | |
| find . -name '*_spec.rb' -exec sed -i.old -e 's/expects/should_receive/' {} \; | |
| find . -name '*_spec.rb' -exec sed -i.old -e 's/stubs/stub/' {} \; | |
| find . -name '*.old' -exec rm {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Totally forgot you can do this:
sedcan take multiple commands — expressions — when you prepend them with the-eswitch. I’ve gotten myself in the habit of specifying that forsedandgrep.