Re: Sightly OT: Unix scripting

2002-03-22 Thread Alex

try...

y=`date '+%y'`
j=`date '+%j'`
#DATE=`date '+%y%j'`
#echo $DATE
ystr=`expr $y - 1`
echo $ystr
if [ ${#ystr} -eq 1 ] 
   then
   ystr=0$ystr
   echo $ystr
fi
DATE=$ystr$j
echo $DATE



On Thu, 21 Mar 2002, Ball, Terry wrote:

 Environment:  Oracle 8.1.6.3 on Solaris 5.8
 
 I am not a Unix Guru by any strech of the imagination, so I can use all the
 help I can get.  I am trying to write a shell script to execute sqlldr of a
 file whose name includes yesterday's 2 digit year and julian day in the
 format: file_yyjjj.csv.  I can get today's date fine by setting a variable
 to be DATE=`date '+%y%j'`
 
 But when I try to get DATE -1 it strips the leading 0 (since it is currently
 02).  Does anyone have any suggestions as to how I can retain the leading 0
 and still get yesterday's date?
 
 TIA,
 
 Terry
 
 Terry Ball, DBA
 Birch Telecom
 Work: 816-300-1335
 FAX:  816-300-1801
 
 -- 
 Please see the official ORACLE-L FAQ: http://www.orafaq.com
 -- 
 Author: Ball, Terry
   INET: [EMAIL PROTECTED]
 
 Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
 San Diego, California-- Public Internet access / Mailing Lists
 
 To REMOVE yourself from this mailing list, send an E-Mail message
 to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
 the message BODY, include a line containing: UNSUB ORACLE-L
 (or the name of mailing list you want to be removed from).  You may
 also send the HELP command for other information (like subscribing).
 

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Alex
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



Sightly OT: Unix scripting

2002-03-21 Thread Ball, Terry

Environment:  Oracle 8.1.6.3 on Solaris 5.8

I am not a Unix Guru by any strech of the imagination, so I can use all the
help I can get.  I am trying to write a shell script to execute sqlldr of a
file whose name includes yesterday's 2 digit year and julian day in the
format: file_yyjjj.csv.  I can get today's date fine by setting a variable
to be DATE=`date '+%y%j'`

But when I try to get DATE -1 it strips the leading 0 (since it is currently
02).  Does anyone have any suggestions as to how I can retain the leading 0
and still get yesterday's date?

TIA,

Terry

Terry Ball, DBA
Birch Telecom
Work: 816-300-1335
FAX:  816-300-1801

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Ball, Terry
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



Re: Sightly OT: Unix scripting

2002-03-21 Thread Brian_P_MacLean


(all examples are using /usr/bin/ksh shell)

You could do it this way:

DATE=$(date '+%y%j')
DATE=$((${DATE} - 1))
[ ${#DATE} -eq 4 ]  DATE=0${DATE}

But you have bigger problems my friend.  What happens if the date is 02001
and you subtract 1.  The result is 02000 which is invalid.  Since you are
in a script that is using the db anyway why not do something like this:

{
  sqlplus -s /nolog EOF
connect /
set pagesize 0
select to_char(sysdate - 1, 'YYDDD') from dual;
exit;
  EOF
} | grep -iv connected | read DATE


Brian P. MacLean
Oracle DBA, OCP8i



   
   
Ball, Terry  
   
[EMAIL PROTECTED]   To: Multiple recipients of list ORACLE-L 
[EMAIL PROTECTED]  
om  cc:   
   
Sent by: Subject: Sightly OT: Unix scripting   
   
[EMAIL PROTECTED] 
   
om 
   
   
   
   
   
03/21/02 12:08 
   
PM 
   
Please respond 
   
to ORACLE-L
   
   
   
   
   




Environment:  Oracle 8.1.6.3 on Solaris 5.8

I am not a Unix Guru by any strech of the imagination, so I can use all the
help I can get.  I am trying to write a shell script to execute sqlldr of a
file whose name includes yesterday's 2 digit year and julian day in the
format: file_yyjjj.csv.  I can get today's date fine by setting a variable
to be DATE=`date '+%y%j'`

But when I try to get DATE -1 it strips the leading 0 (since it is
currently
02).  Does anyone have any suggestions as to how I can retain the leading 0
and still get yesterday's date?

TIA,

Terry

Terry Ball, DBA
Birch Telecom
Work: 816-300-1335
FAX:  816-300-1801

--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Ball, Terry
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).




-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



Re: Sightly OT: Unix scripting

2002-03-21 Thread Jared . Still

I'll show you one way to do it, if you quit calling that a Julian date. :)
( YYDDD is not a Julian date )

$ echo $DATE
2079

$ DATE=$(echo $DATE | awk '{ print substr($1,length($1)-4) 
}')

$ echo $DATE
02079

Jared







Ball, Terry [EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
03/21/02 11:08 AM
Please respond to ORACLE-L

 
To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED]
cc: 
Subject:Sightly OT: Unix scripting


Environment:  Oracle 8.1.6.3 on Solaris 5.8

I am not a Unix Guru by any strech of the imagination, so I can use all 
the
help I can get.  I am trying to write a shell script to execute sqlldr of 
a
file whose name includes yesterday's 2 digit year and julian day in the
format: file_yyjjj.csv.  I can get today's date fine by setting a variable
to be DATE=`date '+%y%j'`

But when I try to get DATE -1 it strips the leading 0 (since it is 
currently
02).  Does anyone have any suggestions as to how I can retain the leading 
0
and still get yesterday's date?

TIA,

Terry

Terry Ball, DBA
Birch Telecom
Work: 816-300-1335
FAX:  816-300-1801

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Ball, Terry
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



RE: Sightly OT: Unix scripting

2002-03-21 Thread Koivu, Lisa

Terry, 

I don't see a format like that in the unix date command formats,
unfortunately.  You may have to test the value and pad the number yourself.
I have to do that in a number of my perl scripts.  

You are lucky you have Unix...

Lisa Koivu
Oracle Database Monkey.
Fairfield Resorts, Inc.
954-935-4117


 -Original Message-
 From: Ball, Terry [SMTP:[EMAIL PROTECTED]]
 Sent: Thursday, March 21, 2002 2:08 PM
 To:   Multiple recipients of list ORACLE-L
 Subject:  Sightly OT: Unix scripting
 
 Environment:  Oracle 8.1.6.3 on Solaris 5.8
 
 I am not a Unix Guru by any strech of the imagination, so I can use all
 the
 help I can get.  I am trying to write a shell script to execute sqlldr of
 a
 file whose name includes yesterday's 2 digit year and julian day in the
 format: file_yyjjj.csv.  I can get today's date fine by setting a variable
 to be DATE=`date '+%y%j'`
 
 But when I try to get DATE -1 it strips the leading 0 (since it is
 currently
 02).  Does anyone have any suggestions as to how I can retain the leading
 0
 and still get yesterday's date?
 
 TIA,
 
 Terry
 
 Terry Ball, DBA
 Birch Telecom
 Work: 816-300-1335
 FAX:  816-300-1801
 
 -- 
 Please see the official ORACLE-L FAQ: http://www.orafaq.com
 -- 
 Author: Ball, Terry
   INET: [EMAIL PROTECTED]
 
 Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
 San Diego, California-- Public Internet access / Mailing Lists
 
 To REMOVE yourself from this mailing list, send an E-Mail message
 to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
 the message BODY, include a line containing: UNSUB ORACLE-L
 (or the name of mailing list you want to be removed from).  You may
 also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Koivu, Lisa
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



Re: Sightly OT: Unix scripting

2002-03-21 Thread Brian_P_MacLean


Yes it's day-of-year.  Some Unix doc's list it as Julian day-of-year.
Same difference...

Brian



   
   
Jared.Still@ra 
   
disys.comTo: Multiple recipients of list ORACLE-L 
[EMAIL PROTECTED]  
Sent by: cc:   
   
[EMAIL PROTECTED]   Subject: Re: Sightly OT: Unix scripting   
   
om 
   
   
   
   
   
03/21/02 01:33 
   
PM 
   
Please respond 
   
to ORACLE-L
   
   
   
   
   




I'll show you one way to do it, if you quit calling that a Julian date. :)
( YYDDD is not a Julian date )

$ echo $DATE
2079

$ DATE=$(echo $DATE | awk '{ print substr($1,length($1)-4)
}')

$ echo $DATE
02079

Jared







Ball, Terry [EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
03/21/02 11:08 AM
Please respond to ORACLE-L


To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED]
cc:
Subject:Sightly OT: Unix scripting


Environment:  Oracle 8.1.6.3 on Solaris 5.8

I am not a Unix Guru by any strech of the imagination, so I can use all
the
help I can get.  I am trying to write a shell script to execute sqlldr of
a
file whose name includes yesterday's 2 digit year and julian day in the
format: file_yyjjj.csv.  I can get today's date fine by setting a variable
to be DATE=`date '+%y%j'`

But when I try to get DATE -1 it strips the leading 0 (since it is
currently
02).  Does anyone have any suggestions as to how I can retain the leading
0
and still get yesterday's date?

TIA,

Terry

Terry Ball, DBA
Birch Telecom
Work: 816-300-1335
FAX:  816-300-1801

--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Ball, Terry
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author:
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).




-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).