Get yesterday date

Hi Friend,

i am using OS

HP-UX vvftf320 B.11.11 U 9000/800 511076331 unlimited-user license

now i have used below command but it giving today's date. i need your help to get yesterdate. Please correct me.

date +"%d%m%Y%H%M%S" -d "1 days ago

Thanks in advance,
Jewel

# date +%d%m%Y%H%M%S -d '1 day ago'
24122012172442

or

# TZ=IST+24 date +%d%m%Y%H%M%S
24122012115735

or Read this thread

The date command in HP-UX does not support -d option, so you can use Perl to get yesterdays date:

perl -e '@T=localtime(time-86400);printf("%02d/%02d/%02d\n",$T[4]+1,$T[3],($T[5]+1900)%100)'

Or you can refer this nice thread created by Perderabo

Hi experts,

1.i used below command to get previous date with DDMMYYYYhh24miss

perl -e 'use POSIX;print strftime "%Y%m%d\n",localtime time-345600;'

but it's not giving the giving correct output. So can you please help.

  1. how i can use this command in shell script.

Regards,
jewel