|
|
|
|
|
by zaidhaan
896 days ago
|
|
It might be worth noting that while ripgrep doesn't support in-place file editing, it's still possible to replace matches using the `-r` flag, couple that with a tool like `sponge` from moreutils[0] and you can effectively perform search and place like such: $ 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)[0] https://joeyh.name/code/moreutils/ |
|
Why so?