Last active
August 6, 2018 18:26
-
-
Save naganowl/5502d58980667ae664791a94bcaacb00 to your computer and use it in GitHub Desktop.
Find/replace except in a directory
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
# https://stackoverflow.com/questions/18046456/excluding-a-directory-from-find-and-sed-rename | |
# https://stackoverflow.com/questions/9704020/recursive-search-and-replace-in-text-files-on-mac-and-linux | |
find app -type f -name '*.erb' -not \( -path 'app/views/helpers/*' \) -exec sed -i '' s/this/that/ {} + | |
# Given a file `sel` of strings, remove all instances of them in all other directories | |
for i in `cat sel` ; do echo $i | cut -c2- | find app -type f -name '*.erb' -not \( -path 'app/views/helpers/*' \) -exec sed -i '' "s/$i//" {} +; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment