The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Compare date from db2 table to yesterday's Unix system date sasaliasim Shell Programming and Scripting 8 04-24-2008 03:04 AM
Perl: Extracting date from file name and comparing with current date MKNENI Shell Programming and Scripting 4 03-26-2008 12:01 PM
date issue-find prevoius date in a patricular format bsandeep_80 UNIX for Advanced & Expert Users 3 11-15-2007 04:42 PM
Changing Creation Date to a Prespecified Date of a File In Unix monkfan UNIX for Dummies Questions & Answers 4 11-28-2006 03:15 AM
a simple way of converting a date in seconds to normal date travian HP-UX 2 11-23-2006 08:25 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-19-2004
Registered User
 

Join Date: Jun 2002
Posts: 5
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Add Date

I have a file with date and time in it YYYYMMDDHHMISS

cat payt_date.dat
20031007201031

and I need to add 10minutes

Any ideas?
Forum Sponsor
  #2 (permalink)  
Old 01-19-2004
oombera's Avatar
Have a day :|
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Is this what you want? If not, explain more about what you're trying to do...

sed 's/20031007201031/20031007202031/g' payt_date.dat
  #3 (permalink)  
Old 01-19-2004
Registered User
 

Join Date: Jun 2002
Posts: 5
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
the date field could be any date/time , I need a shell that works out the date + 10 minutes . I should have explained this.
  #4 (permalink)  
Old 01-20-2004
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,206
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
The shell is not the best tool for date/time arithmetic. Assuming you have perl...
Code:
#!/usr/bin/ksh
touch -t $(sed 's/\(..\)$/.\1/' payt_date.dat) payt_date.dat
perl -e '
  ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
    $atime,$mtime,$ctime,$blksize,$blocks)=stat("payt_date.dat");
  ($ss,$mm,$hh,$DD,$MM,$YY)=localtime($mtime+600);
  printf "%04d%02d%02d%02d%02d%2d\n",$YY+1900,$MM+1,$DD,$hh,$mm,$ss;
' > payt_date_plus_ten.dat
cat payt_date_plus_ten.dat
20031007202031
  #5 (permalink)  
Old 01-20-2004
Registered User
 

Join Date: Jun 2002
Posts: 5
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
:)

thanks
Google UNIX.COM
Closed Thread



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB 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 -7. The time now is 12:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102