Quote:
Originally Posted by aronmelon
Is there a way to Create file name for the prior Sunday of the run_date
|
This is not trivial.
Possible solutions include
perl, ksh93,
GNU date command,
GNU awk.
GNU date:
Code:
last_sunday_yyyymmdd=$(date -d "-$(date +%w) days" +%Y%m%d)
day_of_run=20090523
prior_sunday_yyyymmdd=$(date -d "$day_of_run -$(date -d $day_of_run +%w) days" +%Y%m%d)
GNU awk:
Code:
last_sunday_yyyymmdd=$(awk 'BEGIN{print strftime("%Y%m%d",systime()-86400*strftime("%w",systime()))}')