[ LUGOS ] Formatianje stevilk?

David Klasinc bigwhale at m42.cx
Fri Apr 6 19:44:20 CEST 2001


On Fri, Apr 06, 2001 at 04:37:28PM +0200, Iztok Umek wrote:

> DATE=`date +%d`
> DATE=`expr $DATE - 1`
> 
> 
> Mi namesto 05 vrne 5 v spremenljivki DATE.
> 
> Kako bi preprical, da bi ven dobil 05? (Torej vedno 2 mestno cifro (z vodeco 0 
> ce je potrebno).

DATE=`date +%d`
DATE=`expr $DATE - 1`
LEN=`echo $DATE | wc -c | cut -d " " -f 7`
if [ $LEN -lt 3 ]; then
 DATE=0${DATE}
fi
echo $DATE

Ampak je najbrz se kje kak drug lepsi in hitrejsi nacin... :)


David!
---------------
'What the fuck was that?!'  -- Mayor of Hiroshima



More information about the lugos-list mailing list