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
Grep date from ls -l GenMen Shell Programming and Scripting 1 05-01-2008 09:53 PM
grep time and date ayhanne Shell Programming and Scripting 8 01-06-2008 09:12 AM
grep using date format ali560045 Shell Programming and Scripting 4 12-26-2007 08:59 AM
grep using date format ali560045 Shell Programming and Scripting 8 12-11-2007 06:39 PM
grep for date in file scabral Shell Programming and Scripting 2 05-29-2007 12:27 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 01-09-2009
ssachins ssachins is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 29
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 (permalink)  
Old 01-09-2009
snoop2048 snoop2048 is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 9
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 (permalink)  
Old 01-09-2009
snoop2048 snoop2048 is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 9
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 (permalink)  
Old 01-09-2009
ssachins ssachins is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 29
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 (permalink)  
Old 01-09-2009
SFNYC SFNYC is offline
Registered User
  
 

Join Date: Jun 2008
Location: New York City
Posts: 95
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
  #6 (permalink)  
Old 01-09-2009
ssachins ssachins is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 29
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 !!!

Have a great Weekend !!!
  #7 (permalink)  
Old 01-09-2009
ssachins ssachins is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 29
ohhhhh no

Ya, you are right. I missed out that.

thanks.
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:54 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