Replace all with sed
We can chain ripgrep and sed(1)
together for really powerful replace-all functionality across code bases. This performs a global replace-all of Movepath
with MovePath
across every Rust (.rs
) file:
$ rg --files-with-matches Movepath --glob "*.rs" --color=never \
| xargs -- sed -i "" s/Movepath/MovePath/g
Sed -i
makes it do edits in-place, and -i ""
causes it to not do backups. Of course, this is dangerous, but presumably all changes are checked into Git and any errors can be detected and rolled back with git diff
.