- 论坛徽章:
- 145
|
回复 1# 力哥丶
$ man awk
GAWK(1) Utility Commands GAWK(1)
NAME
gawk - pattern scanning and processing language
SYNOPSIS
gawk [ POSIX or GNU style options ] -f program-file [ -- ] file ...
gawk [ POSIX or GNU style options ] [ -- ] program-text file ...
pgawk [ POSIX or GNU style options ] -f program-file [ -- ] file ...
pgawk [ POSIX or GNU style options ] [ -- ] program-text file ...
...
Time Functions
Since one of the primary uses of AWK programs is processing log files
that contain time stamp information, gawk provides the following func‐
tions for obtaining time stamps and formatting them.
mktime(datespec)
Turns datespec into a time stamp of the same form as returned
by systime(). The datespec is a string of the form YYYY MM
DD HH MM SS[ DST]. The contents of the string are six or
seven numbers representing respectively the full year includ‐
ing century, the month from 1 to 12, the day of the month
from 1 to 31, the hour of the day from 0 to 23, the minute
from 0 to 59, and the second from 0 to 60, and an optional
daylight saving flag. The values of these numbers need not
be within the ranges specified; for example, an hour of -1
means 1 hour before midnight. The origin-zero Gregorian cal‐
endar is assumed, with year 0 preceding year 1 and year -1
preceding year 0. The time is assumed to be in the local
timezone. If the daylight saving flag is positive, the time
is assumed to be daylight saving time; if zero, the time is
assumed to be standard time; and if negative (the default),
mktime() attempts to determine whether daylight saving time
is in effect for the specified time. If datespec does not
contain enough elements or if the resulting time is out of
range, mktime() returns -1.
strftime([format [, timestamp[, utc-flag]]])
Formats timestamp according to the specification in format.
If utc-flag is present and is non-zero or non-null, the
result is in UTC, otherwise the result is in local time. The
timestamp should be of the same form as returned by sys‐
time(). If timestamp is missing, the current time of day is
used. If format is missing, a default format equivalent to
the output of date(1) is used. See the specification for the
strftime() function in ANSI C for the format conversions that
are guaranteed to be available.
systime() Returns the current time of day as the number of seconds
since the Epoch (1970-01-01 00:00:00 UTC on POSIX systems).
|
|