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
Compare date from db2 table to yesterday's Unix system date sasaliasim Shell Programming and Scripting 8 04-24-2008 03:04 AM
option followed by : taking next option if argument missing with getopts gurukottur Shell Programming and Scripting 2 03-17-2008 08:46 AM
I want to get day from the current system date gopskrish UNIX for Dummies Questions & Answers 2 06-24-2005 06:52 AM
system date Prafulla UNIX for Dummies Questions & Answers 1 02-01-2002 02:42 AM
file date vs. system date ober5861 UNIX for Dummies Questions & Answers 8 09-11-2001 11:36 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-05-2008
arag0rn's Avatar
Registered User
 

Join Date: Jan 2008
Posts: 2
awk system date with -d option

Hi

I get problems when using the following command :

Code:
cat logs | awk -F";" '{ system("date -d "1970-01-01 UTC+0100 $1 seconds""); }'
date: date invalide `1968641199401200'
date: date invalide `1968641199381709'
this is what i have in my log file :

Code:
cat logs
1199401200;a
1199381709;b
I don't know where this 196864 comes form

Any idea ?

Thx

Last edited by arag0rn; 01-05-2008 at 07:48 AM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-05-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,423
Code:
while IFS=";" read a b
do
    date -d "1970-01-01 UTC+0100 $a seconds"
done  < file
Reply With Quote
  #3 (permalink)  
Old 01-05-2008
arag0rn's Avatar
Registered User
 

Join Date: Jan 2008
Posts: 2
Thanx but This is not what i want to do

thx for this idea but it does not work for me
I made something that gives the same output your code should give but this is not what i am searching for :

Code:
for mytimestamp in $(cat logs| awk -F";" '{ print $1; }'); do echo $(date -d “1970-01-01 UTC+0100 $mytimestamp seconds”); done
What i want is to replace all the timestamps (first field) in a log file with the date in UTC+0100 format but i want to keep the other fields (file scheme)...

Last edited by arag0rn; 01-05-2008 at 07:49 AM.
Reply With Quote
  #4 (permalink)  
Old 01-05-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,539
If you have GAWK you can use the strftime function or you can fit the script of gostdog74 like:

Code:
while IFS=";" read a b
do
    echo $(date -d "1970-01-01 UTC+0100 $a seconds")";"$b
done  < file
Regards
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:15 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 Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0