首先, 我们来看如何在一个文件中替换指定文本

sed -i 's/originaltext/newtext/g’ file.txt

在多个文件中替换指定文本,我们只需修改对应匹配文件名称即可.

sed -i 's/originaltext/newtext/g’ *.txt

"sed" - More explanation:

* sed = Stream EDitor
* -i = in-place (i.e. save back to the original file)
* The command string:
    * s = the substitute command
    * original = a regular expression describing the word to replace (or just the word itself)
    * new = the text to replace it with
    * g = global (i.e. replace all and not just the first occurrence)
* file.txt = the file name