The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
File disk utilization for 10 days prior videsh77 UNIX for Advanced & Expert Users 2 04-27-2009 09:56 AM
Delete lines prior to a specific date in a log file. ahSher Shell Programming and Scripting 4 04-06-2009 05:19 AM
Identifying prior date in shell script royalibrahim Shell Programming and Scripting 5 12-04-2008 09:38 AM
retrieve the file. rajesh08 UNIX for Advanced & Expert Users 1 10-08-2008 08:56 AM
A script pls( To retrieve database information) rollthecoin Shell Programming and Scripting 3 04-26-2008 04:35 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-26-2009
aronmelon aronmelon is offline
Registered User
  
 

Join Date: May 2009
Posts: 7
script to retrieve file for prior day

Is there a way to Create file name for the prior Sunday of the run_date
if my Run_date =05262009, i need to the file with the
File name= filename.Y20090524.zip

Thanks in advance
  #2 (permalink)  
Old 05-26-2009
colemar colemar is offline
Registered User
  
 

Join Date: Apr 2009
Location: Trento, Italy
Posts: 116
Quote:
Originally Posted by aronmelon View Post
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()))}')

Last edited by colemar; 05-26-2009 at 05:48 PM..
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 08:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0