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
Get date and time for past 1 hour from current date spch2o Shell Programming and Scripting 5 08-29-2008 04:32 AM
Processing a log file based on date/time input and the date/time on the log file primp Shell Programming and Scripting 4 03-16-2008 11:23 AM
String manupulations... cutelucks Shell Programming and Scripting 2 11-24-2007 03:18 AM
Date/Time help ssmiths001 Shell Programming and Scripting 5 01-27-2006 03:40 AM
date and time ker UNIX for Dummies Questions & Answers 3 11-07-2002 11:47 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 08-02-2005
vanand420 vanand420 is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 60
Lightbulb Time & Date Manupulations

Hi friends ,
I have a long file having different fields like :-
F1 F2 YY/MM/DD hh:mm:ss seconds
XYZ PQR 05/06/25 14:15:56 120
XYZ PQR 05/06/28 00:18:36 12
XYZ PQR 05/06/29 23:12:36 1500
I want to subtract the yy/mm/dd in line 2 from yy/mm/dd in line 1 using DATECALC & hh:mm:ss in line(2) from hh:mm:ss in line(1) & compare the output of substraction (obtained in seconds) with the seconds in line(1) and echo whether it is greater than seconds(120). I want the process to repeat for the whole long file. I tried to modify the nawk script given by Vgersh99
according to my need but it did not worked (the script was working fine before adding yy/mm/dd field in the input file). The changes that I made in original script are Bolded.

BEGIN {
FStime=":"
multN=split("3600 60 1", mult, " ");
}
{
n=split($4, timeA, FStime)
time = 0
for(i=1; i <= n; i++)
time += timeA[i] * mult[i]
diff = $5
}
{
date = {printf ("20"substr($3,1,2)" "substr($3,4,2)" "substr($3,7,2)"\n" )}
}

FNR == 1 {
prevTime=time;
prevDiff=diff;
prevdate=date
next;
}
{
print $0 "\t", (((prevdate*8760 + time - prevTime)) > prevDiff ) ? " " : "S"
prevTime=time; prevDiff=diff;prevdate=`datecalc -a prevdate - date`
}

It gives error at line 13
bailing error at line 13
syntax error at line 22
<<< { >>>
Can u help me out.
Thanks in Advance.
 

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 01:22 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