Last active
January 5, 2021 13:02
-
-
Save Rodrigora/61a2233dcad0b4c637e44cc2d0596460 to your computer and use it in GitHub Desktop.
Replace string in files
This file contains 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
# finds all files in app folder with .rb extension | |
# for each file | |
# capitalizes every "cr" strings preceded by a non-letter and followed by a capital letter | |
find app -name '*.rb' -exec sed -i '' -- "s/\([^a-zA-Z]\)[Cc][Rr]\([A-Z]\)/\1CR\2/g" {} + | |
# rename PGIntegrationError -> CRProviderError | |
find app -name '*.rb' -exec sed -i '' -- "s/PGIntegrationError\CRProviderError/g" {} + | |
find app spec config lib -name '*.rb' -exec sed -i '' -- "s/pg_integration_error\?\cr_provider_error\?/g" {} + | |
#shell | |
find . -name '*.rb' -exec sed -i -- "s/CrLoginStatus/CRProviderSubmission/g" {} + | |
find . -name '*.rb' -exec sed -i -- "s/cr_provider_submissiones/cr_provider_submissions/g" {} + | |
find . -name '*.rb' -exec sed -i -- "s/CRProviderSubmissioes/CRProviderSubmissions/g" {} + | |
CRProviderSubmissiones | |
cr_login_status | |
find . -name '*.rb' -exec sed -i -- "s/cr_login_status/cr_provider_submission/g" {} + | |
# finds all files in app folder starting with cr followed by a capital character | |
grep -rn "\b[Cc][Rr]\([A-Z]\)" app | |
grep -rn "\b[\w]?PG[\w]?[Ee]rror" app | |
# find multiple patterns | |
cat log/file.log | grep -P '^(?=.*pattern1)(?=.*pattern2)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment