-   AIX (
-   -   shell script for date (

rajachan 01-24-2013 03:56 AM

shell script for date

how to do a shell script in aix to display 15 day before the current date.

linosaurusroot 01-24-2013 05:17 AM

perl -e 'print scalar localtime (time - (15 * 86400))'

shivaa 01-26-2013 12:44 AM

Not much sure about AIX, but can you try like bash style:

PREVDATE=$(date --date="15 day ago")

David the H. 01-27-2013 02:48 PM

AIX's version of date doesn't have -d, so that won't work.

A quick google turned up this date script. I don't know how well it works:

rajachan 01-28-2013 01:30 AM

thanks linosaurusroot

your command is working

i am getting the result in following format...

sun jan 13 hh:mm::sec 2013

is it possible to display the date in below format..


linosaurusroot 01-28-2013 04:13 AM

"perldoc localtime" shows the breakdown.

NevemTeve 01-28-2013 09:03 AM

you might want to install GNU-date, perhaps by name gdate so you could use this way:


gdate -d'15 days ago' +%d-%b-%y

David the H. 01-31-2013 01:15 PM

You could also use nawk or gawk if you have them (posix awk/mawk don't have time functions).


nawk 'BEGIN{ print strftime( "%d-%b-%y" , systime() - 15 * 86400 ) }'

All times are GMT -5. The time now is 07:47 PM.