bash - Including "cat" command in unix shell Here Document -


i'm trying create here document shell script includes cat command. of course, fails when encountering 2nd cat. i'm performing lot of substitutions well, can't use "doc" escape trick.

myfile="/tmp/myipaddr" cat >/usr/bin/setipaddress <<_doc_  ...       out=`cat $myfile`  ... _doc_ 

i supposed echo file, seems kludgy , have lot of quotes , backticks i'd need escape?!? other thoughts?

suppose file contains

hello world 

as written, script generate contain line

out=hello world 

because command substitution performed immediately.

at least, need quote line in here document as

out="`cat $myfile`" 

i suspect want include literal command substitution in resulting shell script. that, want quote backticks prevent them being evaluated immediately. better still, use recommended form of command substitution, $(...), , quote dollar sign.

cat >/usr/bin/setipaddress <<_doc_  ...       out=\$(cat $myfile)  ... _doc_ 

/usr/bin/setipaddress include line

out=$(cat /tmp/myipaddr) 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -