Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Replace string in files
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.