This article is an example of a shell pipeline for data processing.
It will show you how to replace in bulk a text in multiple file.
Select the file that contains the text to replace
With grep, you can list the path of files containing a pattern
grep -rli 'old-text' *
where the options:
- i will ignore the case
- r will recursively search from the actual directory
- l will suppress the normal output and instead print the name of each file
Replace the text in a file
With sed, you can replace an old text to a new one
sed -i 's/old-text/new-text/g' /file/path # i: in place, the file will be overwritten
Put it together and create the pipeline
grep -rli 'old-text' * | xargs -i@ sed -i 's/old-text/new-text/g' @