-1

I have a problem I am trying to write a script that will allowed me to write on a conf file for so i was trying to use a sed command but it looks like it works but doesn't save it in the file so my script is

sed '/# Load Java configuration/i JBOSS_User=root'  ITg.conf

this should add "JBOSS_User=root" after the line "# Load Java configuration"

How can I do it?

fedorqui
  • 275,237
  • 103
  • 548
  • 598
  • @hek2mgl I don't think it is a duplicate to this one. However, the solutions there may help: you need to say `sed 's/find/replace/' file` and use `-i` to perform in-place replacement. – fedorqui Aug 19 '16 at 14:38
  • 1
    @fedorqui I realized that in the moment I've pressed the button. Unfortunately SO doesn't allow me to change that. However, the answers there will help. Actually there are likely a ton of valid duplicates. – hek2mgl Aug 19 '16 at 14:39

1 Answers1

0

try this;

sed -i '/# Load Java configuration/i JBOSS_User=root'  ITg.conf

before this command, make backup as below;

cp ITg.conf ITg.conf_backup

man sed :

-i[SUFFIX], --in-place[=SUFFIX]

              edit files in place (makes backup if SUFFIX supplied)
Mustafa DOGRU
  • 3,994
  • 1
  • 16
  • 24