Awk/sed help

Dear All,
The row_eff_tmstp (4th field) and row_expr_tmstp(5th field) in below data represents. If row_expr_tmstp is less than row_eff_tmstp I should replace that as null. First record is header record.

I/P
------

DD04 DD040001 DD040001 NO  NO                                       NONE                 NREC 6082
100009|2013-11-10|2014-02-06 17:03:32.601000||0|0|1|0|0|0|0|0|2014-02-06 17:03:32.601000|609358|
85005|2013-10-27|2014-01-06 23:31:44.641000|2014-01-05 23:36:13.189000|0|0|8|0|0||||2014-01-06 23:36:13.191000|152704|
85005|2013-11-03|2014-01-06 23:31:44.641000|2014-01-07 23:36:13.180000|0|0|9|0|0||||2014-01-06 23:36:13.182000|152704|

Expected O/P
-----------

DD04 DD040001 DD040001 NO  NO                                       NONE                 NREC 6082
100009|2013-11-10|2014-02-06 17:03:32.601000||0|0|1|0|0|0|0|0|2014-02-06 17:03:32.601000|609358|
85005|2013-10-27|2014-01-06 23:31:44.641000||0|0|8|0|0||||2014-01-06 23:36:13.191000|152704|
85005|2013-11-03|2014-01-06 23:31:44.641000|2014-01-07 23:36:13.180000|0|0|9|0|0||||2014-01-06 23:36:13.182000|152704|

You mean the 3rd and 4th field?
Using GNU awk

awk -F\| '
  NR>1{
    t1=$3; t2=$4
    gsub(/[-:]/," ", t1); gsub(/[-:]/," ", t2)
    if(mktime(t2) < mktime(t1))
      $4=0
  }1
' OFS=\| infile

--ahamed

1 Like