
awk(1) | awk(1) |
The print statement prints its arguments on the standard output (or on a ®le if >®le or >>®le is present or on a pipe if cmd is present), separated by the current output ®eld separator, and terminated by the output record separator. ®le and cmd can be literal names or parenthesized expressions. Identical string values in different statements denote the same open ®le. The printf statement formats its expression list according to the format (see printf(3)).
The
The customary functions exp, log, sqrt, sin, cos, atan2 are built in. Other
blength [( [ s ] ) ]
Length of its associated argument (in bytes) taken as a string, or of $0 if no argu- ment.
length [( [ s ] ) ] | Length of its associated argument (in characters) taken as a string, or of $0 if no |
| argument. |
rand() | Returns a random number between zero and one. |
srand( [ expr ] ) | Sets the seed value for rand, and returns the previous seed value. If no argument is |
| given, the time of day is used as the seed value; otherwise, expr is used. |
int(x) | Truncates to an integer value |
substr(s, m [, n] )
Return the at most
index( s, t ) Return the position, in characters, numbering from 1, in string s where string t ®rst occurs, or zero if it does not occur at all.
match( s, ere ) Return the position, in characters, numbering from 1, in string s where the extended regular expression ere occurs, or 0 if it does not. The variables RSTART and RLENGTH are set to the position and length of the matched string.
split( s, a[ , fs] )
Splits the string s into array elements a[1], a[2], ..., a[n], and returns n. The separation is done with the regular expression fs, or with the ®eld separator FS if fs is not given.
sub( ere, repl [ , in] )
| Substitutes repl for the ®rst occurrence of the extended regular expression ere in the |
| string in. If in is not given, $0 is used. |
gsub | Same as sub except that all occurrences of the regular expression are replaced; |
| sub and gsub return the number of replacements. |
sprintf( fmt, expr, ... )
String resulting from formatting expr ... according to the printf(3S) format fmt
system(cmd) Executes cmd and returns its exit status
toupper(s) Converts the argument string s to uppercase and returns the result.
tolower(s) Converts the argument string s to lowercase and returns the result.
The
Patterns
Patterns are arbitrary Boolean combinations (with ! &&) of regular expressions and relational expres- sions. awk supports Extended Regular Expressions as described in regexp(5). Isolated regular expressions in a pattern apply to the entire line. Regular expressions can also occur in relational expressions, using the operators Ä and !Ä. /re/ is a constant regular expression; any string (constant or variable) can be used as a regular expression, except in the position of an isolated regular expression in a pattern.
− 2 − | Section 1−35 |
a