O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The systime() function

The systime() function returns the current time of day as the number of seconds elapsed since midnight, January 1 1970, not counting leap seconds. This allows you to create a log file containing a timestamp using a seconds since the epoch format. This function can also be used to compare the timestamp with a file with the current time of day and for measuring how long a GAWK program takes to execute. The following example shows how the systime() function works:

$ vi systime.awkBEGIN    {    print "Timestamp of program run : ", systime()    LOOPS=10000000;    start=systime();    print start;    for (i=0;i<LOOPS;i++) {    }    end = systime();    print end;    totaltime = ( end -start )    print ("totaltime : ", totaltime)}$ awk -f systime.awk

The output ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required