0

I'd like to create a list of words that need to be replaced across multiple HTML files. How can I do that?

eg. replace:

  • cat with dog
  • parrot with monkey
  • fish with tiger

across all HTML files in the selected catalog.

Zanna
  • 70,465
curious
  • 111

1 Answers1

5

You can place multiple sed expressions into a file, and apply them using the -f option:

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

       add the contents of script-file to the commands to be executed

Ex. given

$ cat > file
The cat sat on the mat.
The parrot chewed on a carrot.
The fish was just a fish.

then

$ 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.
steeldriver
  • 136,215
  • 21
  • 243
  • 336