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 > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Date Format biju.mp UNIX for Dummies Questions & Answers 2 12-31-2007 09:56 AM
Date format Knotty UNIX for Dummies Questions & Answers 2 04-11-2007 01:48 PM
Find julian date for given corresponding date srikanthus2002 Shell Programming and Scripting 2 10-10-2006 09:33 PM
convert mmddyy date format to ccyyddd format?? Bhups Shell Programming and Scripting 2 09-27-2006 11:30 PM
How to find Previous date and Coming date arunava_maity UNIX for Dummies Questions & Answers 2 05-24-2001 11:41 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-15-2007
bsandeep_80 bsandeep_80 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 122
date issue-find prevoius date in a patricular format

Hi ,

I have written a shell script that takes the current date on the server and stores it in a file.

echo get /usr/home/data-`date '+%Y%d'`.xml> /usr/local/sandeep/GetFILE.ini

I call this GetFILE.ini file from an sftp program to fetch a file from /usr/home/ as location. The file is in this format data-20071115.xml
I have been succesfull in doing this.

This runs froms tuesday to friday. But on Monday i need to fetch Saturday and Sunday file and i don't know how it can be accomplished in this.

Can anyone help

Thanks,
Sandeep
  #2 (permalink)  
Old 11-15-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,710
The datecalc script in Perderabo's thread on Date Arithmetic - in the FAQ section
will subtract 1, 2, 3... n days from a date and return a date. So you could get
today - 2 = 20071113
  #3 (permalink)  
Old 11-15-2007
synak synak is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 5
Quote:
Originally Posted by bsandeep_80 View Post
Hi ,

I have written a shell script that takes the current date on the server and stores it in a file.

echo get /usr/home/data-`date '+%Y%d'`.xml> /usr/local/sandeep/GetFILE.ini

I call this GetFILE.ini file from an sftp program to fetch a file from /usr/home/ as location. The file is in this format data-20071115.xml
I have been succesfull in doing this.

This runs froms tuesday to friday. But on Monday i need to fetch Saturday and Sunday file and i don't know how it can be accomplished in this.

Can anyone help

Thanks,
Sandeep
This relies on GNU date.
Code:
#!/bin/bash
if [[ $(date +%u) = 1 ]]
then
  echo get /usr/home/data-$(date --date="-2 days" '+%Y%m%d').xml > /usr/local/sandeep/GetFILE.ini
  # some command that calls GetFILE.ini, before it is overwritten.
  echo get /usr/home/data-$(date --date="-1 days" '+%Y%m%d').xml > /usr/local/sandeep/GetFILE.ini
else
  echo get /usr/home/data-$(date '+%Y%m%d').xml > /usr/local/sandeep/GetFILE.ini
fi
  #4 (permalink)  
Old 11-15-2007
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 499
You'll find help to this same query in a simple search too.
Key words: previous date

Cheers,
Cameron
Sponsored Links
Closed Thread

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 01:38 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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