cur*_*ous 0 command-line text-processing
我想创建一个需要在多个 HTML 文件中替换的单词列表。我怎样才能做到这一点?
例如。代替:
cat
和 dog
parrot
和 monkey
fish
和 tiger
跨所选目录中的所有 HTML 文件。
您可以将多个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)