
788
|
Chapter 11: The gawk Programming Language
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
sub
sub(regex, str [, target])
Substitute str for first match of the regular expression regex in the
string target.Iftarget is not supplied, defaults to $0. Returns 1 if
successful, 0 otherwise. Use & in the replacement string to stand
for the text matched by the pattern.
substr
substr(string, beg [, len])
Return substring of string at beginning position beg (counting from
1), and the characters that follow to maximum specified length len.
If no length is given, use the rest of the string.
system
system(command)
Function that executes the specified command and returns its exit
status. The status of the executed command typically indicates
success or failure. A value of 0 means that the command executed
successfully. A nonzero value indicates a failure of some sort. The
documentation for the command you’re running will give you the
details.
awk does not make the output of the command available for
processing within the awk script. Use command | getline to read
the output of a command into the script.
systime
systime( ) {G}
Return a time-of-day value in seconds since midnight, January 1,
1970, UTC.
Example
Log the start and end times of a data-processing program:
BEGIN {
now = systime( )
mesg = strftime("Started at %m/%d/%Y %H:%M:%S",
now)
print mesg ...