![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
| Display Modes | Rate This Thread |
|
|