by zaidhaan · 2y ago · 0 comments
$ rg --passthru search -r replace file.txt | sponge file.txt
And preview changes like this: $ rg --passthru search -r replace file.txt | diff -u file.txt -
Of course, this is only practical when working with a single file. Though I'd imagine if one threw in the `--files-with-matches -0` flags together and piped that into `xargs`, something similar to `rep` could be be achieved. (Not that I'd encourage anyone to do this at all)Why so?
I just personally would feel more confident with using perl for anything to do with multi-file substitutions. In theory, ripgrep with `--passthru` and `-r` should work.