user10042227
user10042227

Reputation: 23

I want to add java option line in file using sed command in shell scripting after the match

Hi want add below line using sed command in shell but it is not copy as same as line below

JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.debug.DebugSecuritySSL=true -Dweblogic.debug.DebugSSL=true -Dweblogic.StdoutDebugEnabled=true  -Dweblogic.log.StdoutSeverityLevel=Debug -Dweblogic.log.LogSeverity=Debug"

It skip "${JAVA_OPTIONS} and "

I try to use sed:

var="JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.debug.DebugSecuritySSL=true -Dweblogic.debug.DebugSSL=true -Dweblogic.StdoutDebugEnabled=true  -Dweblogic.log.StdoutSeverityLevel=Debug -Dweblogic.log.LogSeverity=Debug""
sed -i "/minimumprotocol=/a \
$var" file.txt

Thanks in advance for your help.

Upvotes: 1

Views: 129

Answers (1)

Kent
Kent

Reputation: 195179

You should escape the $:

var="JAVA_OPTIONS=\${JAVA_OPTIONS} -Dwe..."

Upvotes: 1

Related Questions