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
Post a Comment