bash - How to replace a sentence with special chars? -


I am creating a script with openvpn installation on a server, I need one thing to change it to a file In line:

  sed -i 's / export KEY_CONFIG =' $ EASY_RSA / Jopense SLCNF $ EASY_RSA '/ Export KEY_CONFIG = / etc / openvpn / easy-rsa / 2.0 / openssl-1.0. 0.cnf / g /etc/openvpn/easy-rsa/2.0/vars   

I know that there is some escape required to run here, but I'm not sure which one What are the keys you need to escape The Ripya can help?

This is the sentence from the wars file:

  # This variable # should point to the openssl.cnf file #included with easy RSA Export KEY_CONFIG = `$ EASY_RSA / Jopensus LCNF $ EASY_RSA` # to indicate this variable   

: I want to replace the unread line: export KEY_CONFIG = / etc / openvpn / easy -rsa / 2.0 / openssl-1.0.0.cnf (as is)

There are two steps of processing first by Shell, By SAD.

Shell
It depends on which quote (use two or signals). Exclamation marks are interpreted in the form of no special characters except the sign (stran quotes) between signals. Between double quotes you can enter $ SHELL_VARIABLE for example, which will expand in its value.

Sed
You should save ( \ ) these characters: $ * [Regex] and used delimiter (in your case / ) in full sed command [\] ^ .

Then, your order should look like this:

  Export sed -i / s KEY_CONFIG = '$ EASY_RSA \ / Jopense SLCNF $ EASY_RSA` / Export KEY_CONFIG = \ / etc \ / openvpn \ / easy-rsa \ /2.0 \ /openssl-1.0.0.cnf/g '/etc/openvpn/easy-rsa/2.0/vars   

you too You can select other delimiters which are not in your sed command, for example # .

  sed -i 's #export_config =' $ EASY_RSA / Jopense SLCNF $ EASY_RSA` # exported KEY_CONFIG = / etc / openvpn / easy-rsa /2.0/openssl-1.0.0.cnf #g '/etc/openvpn/easy-rsa/2.0/vars    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -