I want to search and replace a string in all files within one directory.

For example, I have the following text in all my Markdown files: Read more.

I want to replace that piece of text in all files with Read more →.

Enter grep and sed - or rather ripgrep and sed.

  1. Go to the directory, and use rg to search.
rg "Read more"
  1. Pipe all files that ripgrep finds to sed and replace the text:
rg "Read more" --files-with-matches | xargs sed -i "s/Read more/Read more →/g"

Further Reading