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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-05-2008
arag0rn's Avatar
arag0rn arag0rn is offline
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 11:48 AM..
  #2 (permalink)  
Old 01-05-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,512
Code:
while IFS=";" read a b
do
    date -d "1970-01-01 UTC+0100 $a seconds"
done  < file
  #3 (permalink)  
Old 01-05-2008
arag0rn's Avatar
arag0rn arag0rn is offline
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 11:49 AM..
  #4 (permalink)  
Old 01-05-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,294
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
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 04:48 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