I have this code:
sed \
$( (( $compress == 1 )) && echo -n '-e /^RMTHOST/ s/$/, compress/' ) \
-e "s|\*\*jobname\*\*|$jobname|g" \
-e "s|\*\*hostname\*\*|$hostname|g" \
-e "s|\*\*hostport\*\*|$hostport|g" \
-e "s|\*\*rmttrailname\*\*|$rmttrailname|g" < $GGPARAMSDIR/pump.template >
$GGPARAMSDIR/$jobname.prm
that almost works like I want. If $compress == 1, I want the sed to include the string -e /^RMTHOST/ s/$/, compress/'. And if $compress != 1, don't include that section.
I'm getting the following error when $compress is 1
sed: -e expression #1, char 10: missing command
When I add a set -x to the script for debugging it expands to the following:
sed -e '/^RMTHOST/' 's/$/,' compress/ -e 's|\*\*jobname\*\*|pssic|g' -e 's|\*\*hostname\*\*|omsssi|g' -e 's|\*\*hostport\*\*|7809|g' -e 's|\*\*rmttrailname\*\*|./dirdat/dsn/rc|g'
Notice the single ticks closing the first -e expression after the /^RMTHOST/, which I'm sure is the cause of my problem. But I can't figure out the syntax to fix it.
FYI, the values of the variables are jobname=pssic, hostname=omsssi, and hostport=7809
Can anyone help?