Solved get the day yesterday

Hewlett-packard / Hp proliant dl380 g5
March 7, 2012 at 06:51:42
Specs: Windows Xp Pro, 2Gb Ram
Hello, I need to get yesterday's date format ddmmyy on a machine SunOS 5.10 Generic_120011 xxxx-14 sun4u sparc SUNW, Sun-Fire-V240

I do:

#
set fecha = `date +"%d%m%y"`
#
echo $fecha
#
@ res = $fecha - 10000
echo $res

The result is 60312 but I need the day with 2 digits 060312 How can I do?

"La experiencia es algo maravilloso. Nos permite reconocer un error cada vez que lo volvemos a cometer.", Franklin P. Jones


See More: get the day yesterday

Report •

#1
March 7, 2012 at 09:19:34
✔ Best Answer
How about using the printf command to force printing 6 characters:

set nres=`printf "%06d\n" $res`
echo $nres


Report •

#2
March 7, 2012 at 22:52:22
Thank you very much, this was what I wanted

"La experiencia es algo maravilloso. Nos permite reconocer un error cada vez que lo volvemos a cometer.", Franklin P. Jones


Report •
Related Solutions


Ask Question