3e18b52snippet1 min read
Find and replace across a repository
A safe one-liner with ripgrep and sed, with a dry run first.
Published
Preview every match first, then apply the change only to files that contain it.
rg -n 'oldName'rg -l 'oldName' | xargs sed -i '' 's/oldName/newName/g' # macOS
rg -l 'oldName' | xargs sed -i 's/oldName/newName/g' # Linux