Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Manipulation

Status
Not open for further replies.

jping45

Technical User
Aug 22, 2001
49
US
Hi all…

Here is my problem, I have reports generated everyday and they are supposed to be sorted out by week ending date. For us the week ends on a Sunday. For example: Reports created Thursday Nov 21 should be found in dir /20021124 (Week ending Sunday, Nov. 24) reports created on Monday Nov 25 should be found in dir /20021201 (Week ending Sunday, Dec. 01).
Any help would be greatly appreciated…


Regards
Jake
 
Try this:
DETERDATE() {
# This will make the directory.
DOW=`/usr/bin/date "+%w"`

if [ ${DOW} -eq 1 ]
then
TZ=TZ-168
DAY=`/usr/bin/date "+%Y%m%d"`
/usr/bin/mkdir -m 777 -p ${DIR}/${DAY}
fi
}

# This will determine which directory it should write to.
DETERDATE
WDIR=`/usr/bin/ls -1d ${DIR}/2002*|/usr/bin/tail -1`

# My script does this....
echo "Hello" >> ${WDIR}/todayslogfile

That should do it...
 
What is TZ=TZ-168 for? TZ is never mentioned before or after that line in the script. What's the point? How can you subtract 168 off something that hasn't been defined yet?

I'm sincerely curious. I am a neophyte and it's very likely I'm missing something obvious.
 
I don't think you are missing anything. I don't see where TZ is referenced anywhere either, and for that matter it is trying to subtract 168 from TZ which isn't even a variable if it was declared because it would have to be ($TZ - 168).
 
TZ - TimeZone - a system-wide variable vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
ah! correct! Time Zone. But what is it being used for, and it isn't preceeded with a &quot;$&quot;, which is probably an oversight.
 
Heh. Well $TZ isn't a systemwide variable on *my* system. (RedHat Linux 7.2). Everybodys' two-cents appreciated. ;)

I thought I was missing something for sure, but now I'm guessing probably not. Thank you each for your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top