The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
String manipulation jerrynimrod Shell Programming and Scripting 2 06-05-2008 08:06 AM
File manipulation blackjack101 UNIX for Dummies Questions & Answers 5 06-11-2007 07:37 PM
awk manipulation Nicol Shell Programming and Scripting 2 07-05-2006 12:51 AM
Help with log manipulation StevePace Shell Programming and Scripting 3 01-31-2006 05:28 PM
manipulation vivekshankar UNIX for Dummies Questions & Answers 13 05-19-2005 12:45 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-31-2006
Registered User
 

Join Date: Jan 2006
Posts: 12
More log manipulation

wasn't sure if this should have a new thread since I'm still working on the same job I asked a question about earlier. But it's a different problem/question so I guess it deserves a new thread....

I have a log with roughly 10000 lines in it, each one has a timestamp. The problem is, the time is logged in GMT and I need to convert to GMT+10 so I can match the lines up to a corresponding entry in another log which has its timestamps set to EST (GMT+10). Anyone know a way to do this??

Thanks in advance
Reply With Quote
Forum Sponsor
  #2  
Old 01-31-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
What is the format of the timestamp ? Give us a sample of how the lines look.

What OS are you on ?
Reply With Quote
  #3  
Old 01-31-2006
Registered User
 

Join Date: Jan 2006
Posts: 12
example line from logfile set to GMT:

01/22/2006 05:41:51 10.224.200.235 \\10.176.45.16\live\3x\mtv\co\vid\AdultShop.3gp

Unfortunately the other log set to GMT+10 looks more like :

2006 Jan 23 23:34:09:129 GMT 10 DAACAdapter.DAACAdapter Debug [Adapter] H3G_DAAC
-00000 " Country :505" tracking=#z2oqrqhLxrWoL-Oqd5zzyOzUzzw#

So the date is in a different format (but I'm not worried about that.... at least not yet.) and the time stamps are 10 hours apart. (those two log extracts are not related by the way, they're just examples cut from the different logs.)

Cheers
Reply With Quote
  #4  
Old 01-31-2006
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
If your system has GNU date, how about....
Code:
$ sed 's/\\/\\\\/g' /var/tmp/logfile | while read date time rest; do
>  timestamp="${date} ${time}";
>  newdate=`date -d "${timestamp} + 10 hours" +"%Y %b %H:%M:%S:00 GMT 10"`;
>  echo "${newdate} ${rest}";
> done
EDIT: Edited to take account of backslashes in input file

Cheers
ZB

Last edited by zazzybob; 01-31-2006 at 09:41 PM.
Reply With Quote
  #5  
Old 01-31-2006
Registered User
 

Join Date: Jan 2006
Posts: 12
Cheers Z

How do I tell if I'm using GNU date?? The response when I run this is

date: illegal option -- d
usage: date [-u] mmddHHMM[[cc]yy][.SS]
date [-u] [+format]
date -a [-]sss[.fff]
10.239.214.212 \\10.176.45.16\live\3x\vws\un\vid\PlayboyM15PromoZGZNR_MP4_AAC_54_8_VQ_L0a_STR.3gp

I'm using SunOS 5.8. I also tried replacing date with /usr/xpg4/bin/date to no avail.
Reply With Quote
  #6  
Old 01-31-2006
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Ah, that'll be no to GNU date then!

Easiest way would be to grab the coreutils package from http://www.sunfreeware.com which contains GNU date.

Or use another method (such as Pederabos datecalc script - search the forums).

Cheers
ZB
Reply With Quote
  #7  
Old 01-31-2006
Registered User
 

Join Date: Jan 2006
Posts: 12
Dont worry, I've transferred the logs to another machine and the output of the script looks good, just double checking it now.

Nice one, I hope you boys on here get paid a lot of money :-) You're definitely worth it!

Cheers

Steve
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:05 PM.


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

Content Relevant URLs by vBSEO 3.2.0