help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: weird output from date w/ TZ


From: Erika Pacholleck
Subject: Re: weird output from date w/ TZ
Date: Thu, 1 Nov 2001 22:20:16 +0100
User-agent: Mutt/1.2.5i

[01.11.01 09:01 -0800] Joshua Franklin <-- :
> I'm trying to build a script that determined whether
> tomorrow is the first of the month, for use in cron.
> I've put together something like:
> 
> if [ $(TZ=CST-24 date +%e) -eq 1 ]; then
>        do_stuff
> fi
> 
> But I'm seeing some weird output from that subshell.
> It seems to be off by about 6 hours:
> [23:05:03]ns1~$ date
> Wed Oct 31 23:05:09 CST 2001
> [23:05:09]ns1~$  echo  $(TZ=CST-24 date +%D)
> 11/02/01
> [23:05:13]ns1~$  echo  $(TZ=CST-18 date +%D)
> 11/01/01
> [23:05:17]ns1~$  echo  $(TZ=CST-19 date +%D)
> 11/02/01
> [23:05:57]ns1~$  echo  $(TZ=CST date)
> Thu Nov 1 05:07:10 CST 2001
> [23:05:19]ns1~$ date --v
> date (GNU sh-utils) 2.0
> Written by David MacKenzie.

This works here, so you might try it:

TOMORROW=` date -d tomorrow +%e `
if [ "${TOMORROW}" = "1" ]; then
    echo "bingo"
fi

My tomorrow is second, but bingo ;)
HTH
-- 
Erika Pacholleck <pchllck.e at gmx dot de>
                 insert vowels of last name



reply via email to

[Prev in Thread] Current Thread [Next in Thread]