下面是两个相似的代码,为什么第一个工作但不是第二个?两个代码的预期输出应为2017/05/14。任何人都可以在圆括号后解释大括号的用法(在第2行)?
> vi varoutput.bt
query_td () { # line 2
bteq << EOBTQ |grep '^>' |sed -e "s/^>//"
.LOGON TDPROD/userid,pass;
select '>'||t.cal_dt from rldmprod_v.cal_dt t where t.cal_dt=current_date;
.LOGOFF;
.QUIT;
EOBTQ
}
var=$(query_td)
echo $var
> ksh varoutput.bt
2017/05/14
> vi testoutput4.bt
testabcd=$(bteq <<EOF |grep '^>' |sed -e "s/^>//"
.LOGON TDPROD/userid,pass;
select '>'||t.cal_dt from rldmprod_v.cal_dt t where t.cal_dt=current_date;
.LOGOFF;
.QUIT;
EOF
)
var=$testabcd
echo $var
> ksh testoutput4.bt # I expect the output is 2017/05/14
*** Failure 5628 Column > not found in rldmprod_v.t.
Statement# 1, Info =0