if statement help

Ray Parrish crp at cmc.net
Tue Sep 29 19:53:05 UTC 2009


David C. Uhrig wrote:
> On Tue, Sep 29, 2009 at 12:01 PM, Ray Parrish <crp at cmc.net> wrote:
>   
>> nowDay=$(date +%A);
>> nowDate=$(date +%d%B%Y);
>> nowTime=$(date +%H:%M);
>> AMorPM=$(date +%H):
>> padsp espeak "$nowDay";
>> padsp espeak "$nowDate";
>> padsp espeak "$nowTime hours":
>> if [$AMorPM -lt 12]
>> then padsp espeak "AM";
>> else
>>        padsp espeak "PM";
>> fi
>>
>> Can anyone tell me why this always says PM, even when %H returns values
>> lower than 12???
>>
>> Thanks for any help you can be.
>>
>> Later, Ray Parrish
>>
>> --
>> The Future of Technology.
>> http://www.rayslinks.com/The%20Future%20of%20Technology.html
>> Ray's Links, a variety of links to usefull things, and articles by Ray.
>> http://www.rayslinks.com
>> Writings of "The" Schizophrenic, what it's like to be a schizo, and other
>> things, including my poetry.
>> http://www.writingsoftheschizophrenic.com
>>
>>
>> --
>> ubuntu-users mailing list
>> ubuntu-users at lists.ubuntu.com
>> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>>
>>     
>
> Hi Ray,
>
>     I'm not sure why it is not working with %H, but why not use %p for
> AM/PM instead of comparing the %H value?
>
> -David C. Uhrig
>   
I missed it while in man date, thanks for the pointer, it's working 
right now with %p. I still wonder why the if statement was not working 
as I expected.

Later, Ray Parrish

-- 
The Future of Technology.
http://www.rayslinks.com/The%20Future%20of%20Technology.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com






More information about the ubuntu-users mailing list