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
simple shell - how to get a parameter typed in a shell script cmitulescu Shell Programming and Scripting 4 01-09-2009 08:45 PM
How to pass a parameter from one Shell-script to another Shell-script subodhbansal Shell Programming and Scripting 2 09-22-2007 06:19 AM
Passing Date as parameter with sh script pankajkrmishra Shell Programming and Scripting 1 08-15-2006 07:38 AM
Shell script with input parameter jhmr7 UNIX for Dummies Questions & Answers 1 07-13-2005 01:04 AM
parameter file for a shell script bryan Shell Programming and Scripting 2 02-25-2005 12:58 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-09-2008
vinayrao vinayrao is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 7
Shell script with date parameter

Hi All

I have a shell script which calls all the Teradata Utiltyes . There is a sudden change in the requirment .

What i'm asked to do is

pass on the DATE to the shell script which should take the date automatically and run the utilityes.

i.e. the date should not be passed on manulay.The date should be taken automatically.

Please suggest me something on this.

Thanks,
Vinay
  #2 (permalink)  
Old 12-09-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,400
whats the date format that your script takes??
can you post the script??
  #3 (permalink)  
Old 12-09-2008
vinayrao vinayrao is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 7
date parameter format

The date parameter is something like this

'20050101',20080101.
Irrespective of the date is correct or not we take the date with an intreval of 3 years.But that is the date format like

"yyyymmdd".
Please suggest me something

thanks,
Vinay
  #4 (permalink)  
Old 12-09-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
Is this what you are looking for?

Code:
#  date '+%Y%m%d'
20081209
#  date --date='-3 years' '+%Y%m%d'
20051209
#  date --date='3 years' '+%Y%m%d'
20111209
  #5 (permalink)  
Old 12-09-2008
vinayrao vinayrao is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 7
Date automatically

But will the shell script take the DATE automatically , If this condition is passed. I mean to ask is i dont want give the date maually.

When i run the script,it should take the date automatically.
  #6 (permalink)  
Old 12-09-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
Code:
TODAY=`date '+%Y%m%d'`
YEARSAGO=`date --date='-3 years' '+%Y%m%d'`
echo "Today: $TODAY  3 Years Ago: $YEARSAGO"
Code:
# sh test.sh
Today: 20081209  3 Years Ago: 20051209
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

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 07:52 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