if statement help

Nils Kassube kassube at gmx.net
Tue Sep 29 22:11:19 UTC 2009


Ray Parrish wrote:
> Nils Kassube wrote:
> > if [ $AMorPM -lt 12 ]

> I tried adding the spaces, and still it bombs and says PM only.

Not for me. Try this:

AMorPM=$(date -d "11:59" +%H)
if [ $AMorPM -lt 12 ]
then echo AM
else echo PM
fi

Here the output is "AM". And if I change the "11:59" to "12:00" I get 
"PM".


Nils





More information about the ubuntu-users mailing list