grep tomorrow's date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grep tomorrow's date
# 1  
Old 01-09-2009
grep tomorrow's date

Hi guys,

I need to find tomorrows date in date fomat and should be in variable.
as I need to grep this date in a flat file

ie. if today's date is '09 JAN 2009'

output should be '10 JAN 2009'

unix/perl script will be fine.
# 2  
Old 01-09-2009
date | awk '{print $1,$2,$3 + 1,$4}'


From....


simon@cartman:~$ date
Fri Jan 9 15:09:45 GMT 2009
simon@cartman:~$ date | awk '{print $1,$2,$3 + 1,$4}'
Fri Jan 10 15:09:46
simon@cartman:~$
# 3  
Old 01-09-2009
Just realised....You would of course have to wrap this in a if statement to ensure the dates, months, years roll.

A better way would be to increment the unix time stamp by the correct integer (seconds in 24 hours), and then convert to the normal date.
# 4  
Old 01-09-2009
Thanks for your quick reply

I am gettting the output as

Fri Jan 10 10:16:39 -- 10th Jan is SAT

but i need

10 Jan 2009 format.
# 5  
Old 01-09-2009
Code:
myvar=`date '+%d %b %Y' --date="next day"`
echo $myvar

Code:
myvar=`date '+%d %b %Y' --date='1 days'`
echo $myvar

Code:
myvar=`date '+%d %b %Y' --date="tomorrow"`
echo $myvar

Code:
myvar=` date '+%d %b %Y' --date="-1 days ago"`
echo $myvar


Last edited by Ikon; 01-09-2009 at 11:40 AM..
# 6  
Old 01-09-2009
If you have GNU date:

Code:
$ date --version
date (coreutils) 5.2.1
Written by David MacKenzie.

Copyright (C) 2004 Free Software Foundation, Inc.

$ date -d 'tomorrow' +'%d %b %Y'
10 Jan 2009

# 7  
Old 01-09-2009
Working !!

Hello All,

'snoop2048' solutions is working after some changes.

`date | awk '{print $3 + 1,$2,$6}'`

Thank you all for your quick response. Appreciated !!!Smilie

Have a great Weekend !!!
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Rebuilding computer tomorrow at work

I'm rebuilding my primary computer at work tomorrow. Currently, it has Windows 7. I would like to replace the main system with either Linux or Unix, although I would like to be able to run a fully operational Windows as a VM within that. Any recommendations on which Linux or Unix to go with? I'm... (6 Replies)
Discussion started by: Sean_
6 Replies

2. Shell Programming and Scripting

How to get tomorrow,yesterday date from date Command

Hi I want to get tomorrow and yesterday date from date command. My shell is KSH and server is AIX. I tried several options, but unable to do. Please help on this. Regards Rajesh (5 Replies)
Discussion started by: rajeshmepco
5 Replies

3. Shell Programming and Scripting

Calculating expiry date using date,sed,grep

Hi, I would greatly appreciate it if someone can help me with my problem. I have a crawler which collects spam URLs everyday & this data needs to be published in a blacklist. Here's the catch: The "Time To Live" (TTL) for each URL is 3 months (or whatever for that matter). If i see the... (5 Replies)
Discussion started by: r4v3n
5 Replies

4. Homework & Coursework Questions

hey guys i need our help to be passed tomorrow.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: log in time and about the recyclebin 2. Relevant commands, code, scripts, algorithms: im not sure what to... (2 Replies)
Discussion started by: skypigeon
2 Replies

5. UNIX for Dummies Questions & Answers

hey guys i need our help for my assignment to be passed tomorrow.

good day to all. im just a new member. since im a newbie in UNIX, im having trouble learning. problem #1 problem # 2 thank you guys. take good care! (1 Reply)
Discussion started by: skypigeon
1 Replies

6. UNIX for Dummies Questions & Answers

Date change to tomorrow

I have this code in a script that says it is calculating current date: cur_date=`date -u +%m/%d/%Y` If the script is run today during the day, it returns 12/11/2008 If the script is run today during the night, it returns 12/12/2008 Why does it return tomorrow's date if it was run at... (2 Replies)
Discussion started by: mkoay
2 Replies

7. UNIX for Dummies Questions & Answers

Have an interview tomorrow just wondering one thing...

Hi, just a quick question here. I have an interview coming up tomorrow. The job is for a UNIX System Admin. I have a degree in Computer Networking and am familiar with Solaris, but was wondering what should I brush up on before going in to this interview (like any online reference)? Thank you... (2 Replies)
Discussion started by: NELS
2 Replies
Login or Register to Ask a Question