Need simple script to generate future dates


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need simple script to generate future dates
# 1  
Old 08-11-2014
Need simple script to generate future dates

Hi All,

I am looking into a script which will give me a future dates for 7 days, including next month dates in case if runs on month ends...

I an able to get this in Linux but not working for Solaris.

OS: Solaris 10

Please help
# 2  
Old 08-11-2014
try
Code:
#tomorrow
perl -e 'print scalar localtime(time + 86400), "\n";'
#2nd day or day after tomorrow
perl -e 'print scalar localtime(time + 86400*2), "\n";'
#3rd day from today
perl -e 'print scalar localtime(time + 86400*3), "\n";'
and so on...

Additionaly you can format the date format using below parameters
Code:
perl -MPOSIX -le 'print strftime "%Y-%m-%d-%H.%M.%S", localtime(time + 86400)'

This User Gave Thanks to Makarand Dodmis For This Post:
# 3  
Old 08-11-2014
Thanks it is running...

can you help me in printing this in yyyy_mm_dd format....
# 4  
Old 08-11-2014
Hi Mate
try
Code:
perl -MPOSIX -le 'print strftime "%Y_%m_%d", localtime(time + 86400)'

This User Gave Thanks to Makarand Dodmis For This Post:
# 5  
Old 08-11-2014
You Rock Dude !!!!! Smilie
I tried the first.. but haven't tried the second... it helped me now.....

Thanks a lot once again !!!! ........

---------- Post updated at 11:40 AM ---------- Previous update was at 10:17 AM ----------

Another suggestion....

can we convert a text file with delimiters to .xls in solaris...
# 6  
Old 08-12-2014
Buddy
try
Code:
tr ',' '\t' < mak.txt > mak.xls

Here delimeter is comma..change the command if your delimeter id different
This User Gave Thanks to Makarand Dodmis For This Post:
# 7  
Old 08-13-2014
thanks dude...
it worked, but i now have another issue... let me tell you my exact requirement (as of now)... hope my tl will not change this..

my log file has 16 colums with " ; " as delimiter, but i need randomn columns 1 2 3 4 5 6 10 11 16 in an excel.

I tried to awk the columns with delimiter ; and it worked, below is the log after awk.


Code:
  

Sun Aug 10 00:02:06 2014  status  ACK  Administrator admin  0  Sat Aug 09 23:17:41 2014  loret   ctn1029  MAJOR
Sun Aug 10 00:02:17 2014  ticket_number  Administrator admin  0  Sat Aug 09 23:17:41 2014  loret   ctn1029  MAJOR
Sun Aug 10 00:04:21 2014  status  ACK  Administrator admin  0  Sat Aug 09 23:53:20 2014  loret  ctn68  WARNING
Sun Aug 10 00:04:21 2014  status  ACK  ldapuser1 admin  0  Sat Aug 09 23:53:20 2014  loret  ctn1342  WARNING

Now i need this in an excel... I beleive tr command will work, but need to know delimiter id for tab... tried with /t but dint help.. please suggest...

Here data in columns are

Code:
column 1: Sun Aug 10 00:02:05 2014
Column 2:  status
Column3: ACK
Column4 Administrator
Column5: admin
Count6: 0 
Column7: Sat Aug 09 23:53:20 2014  
Column8: loret  
Column9: ctn1342  
Column10: WARNING


Last edited by nanz143; 08-14-2014 at 11:40 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to read a log file and run 2nd script if the dates match

# cat /tmp/checkdate.log SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 17 22:49:00 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production FIRST_TIME NEXT_TIME... (1 Reply)
Discussion started by: SarwalR
1 Replies

2. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

3. UNIX for Dummies Questions & Answers

Generate dates

let says, today is my payroll day (7/26), my next payroll day will be 8/9. i want to generate a shell script to extract 8/9, 8/23, 9/6, and so on for 2010. (2 Replies)
Discussion started by: tjmannonline
2 Replies

4. Shell Programming and Scripting

Future dates.

If I have a script that writes the name of the file based on today, tomorrow, and the day after tomorrow. How would I modify the line echo "filename.${PDY}${CYC}" >>CONTROL to reflect tomorrow and the day after tomorrow and write it to the file called CONTROL? Since ${PDY} shows... (2 Replies)
Discussion started by: libertyforall
2 Replies

5. Shell Programming and Scripting

Perl script that checks against Future time

Ok, so this may be an unusual request. But I have a certificate that expires sometime in may of 2011. Now, i have to monitor this certificate and alert when the current time is within 30 days of may 20, 2011. #!/usr/bin/perl # use Time::Local; # $sec=59; $min=59; $hours=23; $day=31;... (3 Replies)
Discussion started by: SkySmart
3 Replies

6. Shell Programming and Scripting

Generate quarter dates with begin date and end date

Hi All, I am trying to generate quarter dates with user giving input as begin date and end date. Example: Input by user: begin_date = "2009-01-01" end_date = 2010-04-30" required output: 2009-01-01 2009-03-31 09Q01 2009-04-01 2009-06-30 09Q02 . . till 2010-01-01 2010-03-31 10Q01 ... (9 Replies)
Discussion started by: sol_nov
9 Replies

7. Shell Programming and Scripting

Shell script to generate daily crontab entries between to specific dates

Hi, I am currently writing a shell script to enter daily reoccurring jobs into the crontab. I want to be able to specify any two dates for which I want these daily jobs to run between. Below is an example of what I need to be written to crontab. # Give a start day of 21/10/2009 09:00... (2 Replies)
Discussion started by: JM_86
2 Replies

8. Shell Programming and Scripting

Need script to generate all the dates in DDMMYY format between 2 dates

Hello friends, I am looking for a script or method that can display all the dates between any 2 given dates. Input: Date 1 290109 Date 2 010209 Output: 300109 310109 Please help me. Thanks. :):confused: (2 Replies)
Discussion started by: frozensmilz
2 Replies

9. Shell Programming and Scripting

To get previous or future dates based on input value

Hi, I need something like, if the input date is 24/Aug/2008 and the inputvalue is +8 then the result should be 1/Sep/2008 (8 days after the input date) if the input date is 24/Aug/2008 and the inputvalue is -8 then the result should be 16/Aug/2008 (8 days before the input date) is there any... (5 Replies)
Discussion started by: Sharmila_P
5 Replies

10. Shell Programming and Scripting

Checking for future / non existent dates

'm attempting to script an application for the bash shell. The application needs to check for birthday, but must check the birthday to see if the date is a) in the future b) exists at all (ie Feb 29th during non-leap years). The input is being entered in a YYYYMMDD format, so I was hoping someone... (2 Replies)
Discussion started by: DKNUCKLES
2 Replies
Login or Register to Ask a Question