awk 打印帮助 cshell 脚本
我有 sql 脚本:
SPOOL &1
Select to_char(min(calen_dt),'mm-dd-YY') FD,
to_char(max(calen_dt),'mm-dd-YY') LD
from put_calen
where calen_dt >= trunc(sysdate,'mm') - interval '1' month
and calen_dt <= trunc(sysdate,'mm') - interval '1' day
and business_day_ind = 'Y';
SPOOL OFF
将其输出转储到 get.tmp
我的问题是如何在我的 cshell 脚本中设置最小和最大日期,以便我可以使用该日期..我这样做的方式..它不起作用..我做什么需要在这里改变
sqlplus $ORA_UID/$ORA_PSWD @${SQL}example.sql ${TMP}get.tmp
set first_date=`cat ${TMP}/get_date.tmp | awk -F '{print $1}'`
echo 'First Date: '${first_date}
set last_date=`cat ${TMP}/get_date.tmp | awk -F '{print $2}'`
echo 'Last Date: '${last_date}
I have sql script :
SPOOL &1
Select to_char(min(calen_dt),'mm-dd-YY') FD,
to_char(max(calen_dt),'mm-dd-YY') LD
from put_calen
where calen_dt >= trunc(sysdate,'mm') - interval '1' month
and calen_dt <= trunc(sysdate,'mm') - interval '1' day
and business_day_ind = 'Y';
SPOOL OFF
that dumps it output to get.tmp
my question is how can i set min and max date in my cshell script so i can use that date.. the way i did it.. it didnt work.. what i need to change here
sqlplus $ORA_UID/$ORA_PSWD @${SQL}example.sql ${TMP}get.tmp
set first_date=`cat ${TMP}/get_date.tmp | awk -F '{print $1}'`
echo 'First Date: '${first_date}
set last_date=`cat ${TMP}/get_date.tmp | awk -F '{print $2}'`
echo 'Last Date: '${last_date}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您由于其他原因不需要 awk,我建议改用 cut :
我还冒昧地删除了前导的“cat”,因为 grep 也可以从命令行获取文件
If you don't specifically need awk for some other reason, I'd suggest using cut instead :
I also took the liberty of removing the leading 'cat' since grep may as well take the file from the command line