How to do Date Manupulation in Korn Shell?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to do Date Manupulation in Korn Shell?
# 1  
Old 03-17-2013
Power How to do Date Manupulation in Korn Shell?

Hi All,

I need to find the date 19days back from the current date:
eg: if today is 17 March 2013
then the output should be : 26 Feb 2013

Can i do this using date command in Korn Shell?

And also if i need future 15 days date from current date, how to that?

Any help appreciated Smilie

Thanks in advance
# 2  
Old 03-17-2013
With GNU date:
Code:
date -d"-19 days" +"%d-%b-%Y"
date -d"+15 days" +"%d-%b-%Y"

# 3  
Old 03-17-2013
Thanks for the reply but after executing the above script i got following error:
Code:
date: illegal option -- d
Usage: date [-u] [+format]
       date [-u] [mmddhhmm[[cc]yy]]
       date [-a [-]sss.fff]

It's korn shell UNIX AIX. Any other suggestions?
# 4  
Old 03-17-2013
Have a look at this thread
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk for string manupulation

Hi All, I have one file with two columns separated by tab. I need to search for second column value of this file in the 5 column of another file. If the match is found replace the 5th column of second file with entire row of the first file. e.g. file1 123 D.abc 234 D.rde 4563 ... (2 Replies)
Discussion started by: alok2082
2 Replies

2. Shell Programming and Scripting

CDR manupulation

Hello Friends, I need to examine a huge CDR file according to a complex (at least for me) condition like below and i couldnt write anything :( In CDR file there are more than hundreds of fields, I need to print the rows which matches the below condition: while $13 field of subsequent... (9 Replies)
Discussion started by: EAGL€
9 Replies

3. Shell Programming and Scripting

Bourne shell & Korn shell

Could some one tell me the difference btw Bourne shell and the Kshell? Which is more flexible and reliable in terms of portability and efficiency. When i type the following command .. $ echo $SHELL yields me /bin/sh Does this tells me that I am in Bourne shell. If yes, how can i get... (6 Replies)
Discussion started by: bobby1015
6 Replies

4. Shell Programming and Scripting

Korn Shell Date Formatting

I am serching for a file created today like so: TODAY=$(date +"%b-%d") T_FILE=$(find /export/home/dan/ck/reports/t-status-t.txt-$TODAY-05-00-0?.csv) The file it is searching for is titled: /export/home/dan/ck/reports/t-status-t.txt-Jun-29-05-00-01 however, I when... (2 Replies)
Discussion started by: ther2000
2 Replies

5. Shell Programming and Scripting

How to activate Korn Shell functionnalities in Bourne Shell

Hi All I have writing a Korn Shell script to execute it on many of our servers. But some servers don't have Korn Shell installed, they use Borne Shell. Some operations like calculation don't work : cat ${file1} | tail -$((${num1}-${num2})) > ${file2} Is it possible to activate Korn Shell... (3 Replies)
Discussion started by: madmat
3 Replies

6. Shell Programming and Scripting

Korn Shell Script - Getting yesterdays date

I need to get yesterdays date in the format yyyymmdd I can get today's date simply enough - 20031112 Is there any way to substract 1 from this easily enough in korn shell script? It has to be korn shell and not perl (20 Replies)
Discussion started by: frustrated1
20 Replies

7. UNIX for Dummies Questions & Answers

records manupulation

I am sending the data in userfile and colfile from ksh script to pl/sql script linto an array with this command grep '' $userfile |awk '{print "my_user_id("FNR") := '$SQL_QUOTE'"$1"'$SQL_QUOTE';"}' >> $SQL_TEMP_FILE grep '^\{1,10\}$' $colfile | awk '{print "my_col_id("NR") := "$1";"}' >>... (0 Replies)
Discussion started by: pinky
0 Replies

8. Shell Programming and Scripting

Date Manupulation

HI all, I am relatively new to Unix Shell Scripts ... I want to know how u can calculate the differnece between the 2 dates. As if in Oracle by using SYSDATE u get current date and time .. How one can achieve it in Unix ? Thanks.. (1 Reply)
Discussion started by: dhananjaysk
1 Replies

9. Shell Programming and Scripting

how to convert from korn shell to normal shell with this code?

well i have this code here..and it works fine in kornshell.. #!/bin/ksh home=c:/..../ input=$1 sed '1,3d' $input > $1.out line="" cat $1.out | while read a do line="$line $a" done echo $line > $1 rm $1.out however...now i want it just in normal sh mode..how to convert this?... (21 Replies)
Discussion started by: forevercalz
21 Replies

10. Shell Programming and Scripting

KORN Shell - Spawn new shell with commands

I want to be able to run a script on one server, that will spawn another shell which runs some commands on another server.. I have seen some code that may help - but I cant get it working as below: spawn /usr/bin/ksh send "telnet x <port_no>\r" expect "Enter command: " send "LOGIN:x:x;... (2 Replies)
Discussion started by: frustrated1
2 Replies
Login or Register to Ask a Question