开发者

awk printing help cshell script

开发者 https://www.devze.com 2023-02-20 22:24 出处:网络
I have sql script : SPOO开发者_JAVA百科L &1 Select to_char(min(calen_dt),\'mm-dd-YY\') FD, to_char(max(calen_dt),\'mm-dd-YY\') LD

I have sql script :

SPOO开发者_JAVA百科L &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}


If you don't specifically need awk for some other reason, I'd suggest using cut instead :

set f1=grep G1 ${TMP}/get.tmp | cut -d= -f2

I also took the liberty of removing the leading 'cat' since grep may as well take the file from the command line

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号