0

I am trying to use sed in a bash file to add the following after it finds AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>

To simplify things I am focusing just on adding the first line until I get it right, I have this so far.....

sed '/AddDefaultCharset UTF-8/a <IfModule mime_magic_module>' /home/testfile.ini

But when I try running this it just echos out the entire file, where am I going wrong?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
fightstarr20
  • 237
  • 1
  • 3
  • 9

1 Answers1

1

Use -e before your sed command(s).

sed -e '/AddDefaultCharset UTF-8/a <IfModule mime_magic_module>\n    MIMEMagicFile conf/magic\n</IfModule>' your_conf_file.ini

NOTE: You can use -i.bak to perform inplace edit and create a backup with .bak (or any other suffix).

benaja
  • 52