linux - How to find a text string within a config file and add two new lines below with one single line command? -


I'm trying to fight that pedal SSL bug and I have to change a lot of configuration files.

I try to save myself some work and this is done by a single line command, thus I need to modify - for example - /etc/lighttpd/lighttpd.conf.

I am looking for ssl.engine = "enable"

and I want to add two new lines found with the following string:

  Ssl.use-sslv2 = "disable" ssl.use-sslv3 = "disable"  

The end result should be:

  $ server [ "Socket"] == "0.0.0.0:80" {ssl.engine = "enabled" ssl.use-sslv2 = "disabled" ssl.use-SSLv3 = "disable" ssl.pemfile = "/ etc / ssl / Cert.pem "ssl.ca- file =" /etc/ssl/cert.bundle "}  

I tried with the AWC but I used to work due to spaces and carriage returnsNew it can not achieve.

Someone is happy to see a liner :)

Here is what I have tried (of course something wrong here):

 < Code> awk '{a [NR] = $ 0} /ssl.engine/ {a [NR + 1] = a [nr + 1] "ssl.use-sslv2 =" disable ""} {single . + 2] "ssl.use-SSLv3 =" disabled ""} {For the end (i = 1; i  

  awk '{print} /ssl\.engine = "ext" itemprop = "enable text" / {print} ssl.use-sslv2 = \ "disabled \" \ nssl.use-sslv3 = \ "Disable \" "} 'file  

Note that'. 'Is an RE Metacrector, so it needs to be re-saved in context.

If you use the original file Want to modify GNU with one:

  awk -i inplace '...' file  

and any awk or any other Unix device With:

  awk '...' file & gt; Tmp & Mv tmp file  

explicitly:

  awk -i inplace '{print} /ssl\.engine = "enable" / {print "ssl.use -sslv2 = \" disable \ "\ nssl.use-sslv3 = \" disable \ ""} File awk "{print} /ssl\.engine =" enable "/ {print" ssl.use-sslv2 = \ "disable \" \ nssl.use-sslv3 = \ "disable \" "} 'File & gt; TMP & amp; Mv tmp file  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -