![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
What is the format of the timestamp ? Give us a sample of how the lines look.
What OS are you on ? |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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
Cheers ZB Last edited by zazzybob; 01-31-2006 at 09:41 PM. |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
||||
|
||||
|
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 |
|
#7
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |