Very simple utility to replace(r)/delete(d) strings in text files
cargo install rd
rd "replace" "with" -f file.txt
by default, it uses regex, for string literals
rd -s "replace" "with" -f file.txt
rd "replace" "with" -f file.txt -i
rd "to_add" -f file.txt -a 1 # line number to add
rd "to_delete" -f file.txt -d
rd "replace" "with" -f *.txt
with fd
rd "replace" "with" -f $(fd '.*\.txt')
Much faster than GNU sed (2x), but slower than sd (2x) for large files. Similar to sd for small files
- Do not touch the file unless there is a change. This is useful when modifying a long list of files and do not want to leave a trail in every files pass on the command line