I am using the following Perl one liner in a ksh script to process a file of dates and change them to a different format and attach a counter of 1 to each date processed.
I must have something wrong, when I have entries like:
which is Fri Mar 18 17:27:46 2011 for which I would expect an output of the form:
2011 03 18 05 21 1
this code returns:
2011 03 18 05 17 1
This is the code I use :
perl -lne '($j1,$j2,$hour,$mday,$mon,$year,$wday) = gmtime($_);$year =
+ $year + 1900;$mon++;printf("%4s %.2d %.2d %.2d %.2d %6s\n",$year,$mo
+n,$mday,$wday,$hour,1);' < inputFile >outputFile
I really hope someone can help and explain my error.