如何在多个html文件中查找和替换多个字符串?

cur*_*ous 0 command-line text-processing

我想创建一个需要在多个 HTML 文件中替换的单词列表。我怎样才能做到这一点?

例如。代替:

  • catdog
  • parrotmonkey
  • fishtiger

跨所选目录中的所有 HTML 文件。

ste*_*ver 5

您可以将多个sed表达式放入一个文件中,并使用以下-f选项应用它们:

-f script-file, --file=script-file

       add the contents of script-file to the commands to be executed
Run Code Online (Sandbox Code Playgroud)

前任。给予

$ cat > file
The cat sat on the mat.
The parrot chewed on a carrot.
The fish was just a fish.
Run Code Online (Sandbox Code Playgroud)

然后

$ cat > sedfile
s/cat/dog/g
s/parrot/monkey/g
s/fish/tiger/g

$ sed -f sedfile file
The dog sat on the mat.
The monkey chewed on a carrot.
The tiger was just a tiger.
Run Code Online (Sandbox Code Playgroud)