Ban
Ban

Reputation: 349

How to create string for using variables inside string in shell-script

Hi My variable is not getting String using shell-script

I try to create string variable But getting Error :- "Missing }."

log_handler_ws_async="<property name='path' value='"${domain.home}"/servers/"${weblogic.Name}"/logs/async.log'/>"

When we use this variable. it's will get same string... we don't want value for this ${weblogic.Name}

echo $log_handler_ws_async

expected output:-

"<property name='path' value='"${domain.home}"/servers/"${weblogic.Name}"/logs/async.log'/>"

Upvotes: 1

Views: 36

Answers (1)

anubhava
anubhava

Reputation: 786319

You may use read builtin with heredoc:

read -r log_handler_ws_async <<-'EOF'
<property name='path' value='"${domain.home}"/servers/"${weblogic.Name}"/logs/async.log'/>
EOF

echo "$log_handler_ws_async"

<property name='path' value='"${domain.home}"/servers/"${weblogic.Name}"/logs/async.log'/>

Upvotes: 1

Related Questions