Reputation: 514
Hi Stackoverflow users,
Normally I can use sed pretty wel (often need a few tries). However I am having issues with adding the text below at the end of the file:
<linebreak/empty line here>
[extensions]
blacklist = "google-authenticator"
Into a file called: /usr/local/psa/admin/conf/panel.ini
To make things "more" complicated, I also use the command in OpenVZ automation. Like this:
vzctl exec $VEID 'sed XX "VALUE FROM ABOVE" /usr/local/psa/admin/conf/panel.ini'
Can someone provide some help and/or direct me in the right direction?
Obviously I tried a few things, but I think I am having issues with the extra quotes in the text I am trying to add.
Errors are always something like this:
So I am doing something wrong and I have no clue how to correctly add the above. Preferably with a line-break in front.
I hope I explained the issue correctly. Thanks in advance for your assistance.
//Edit
All I need is a solution to add the following text:
<linebreak/empty line here>
[extensions]
blacklist = "google-authenticator"
by using sed.
So I can apply it to my script which creates an OpenVZ container (automated) like: vzctl exec $VEID 'possible sed solution here' /file-name
Sorry if I wasn't clear before.
Upvotes: 0
Views: 4126
Reputation: 7499
Try using this GNU sed
:
'sed -i '\''$a \\n[extensions]\nblacklist = "google-authenticator"'\'' /usr/local/psa/admin/conf/panel.ini'
-i
: edit files in place$
: address matching the last linea text
: append text after a lineJust like @Kent recommended in his deleted answer, it would be more readable and simpler to save the text you want to append into a file and use the r file
command to sed
.
Upvotes: 1