Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
awk(1)
Edit
PageHistory
Diff
Info
LikePages
MAWK !!!MAWK NAME SYNOPSIS DESCRIPTION OPTIONS THE AWK LANGUAGE EXAMPLES COMPATIBILITY ISSUES SEE ALSO BUGS AUTHOR ---- !!NAME mawk - pattern scanning and text processing language !!SYNOPSIS __mawk__ [[-__W__ ''option''] [[-__F__ ''value''] [[-__v__ ''var=value''] [[--] 'program text' [[file ...]__ mawk__ [[-__W__ ''option''] [[-__F__ ''value''] [[-__v__ ''var=value''] [[-__f__ ''program-file''] [[--] [[file ...] !!DESCRIPTION __mawk__ is an interpreter for the AWK Programming Language. The AWK language is useful for manipulation of data files, text retrieval and processing, and for prototyping and experimenting with algorithms. __mawk__ is a ''new awk'' meaning it implements the AWK language as defined in Aho, Kernighan and Weinberger, ''The AWK Programming Language,'' Addison-Wesley Publishing, 1988. (Hereafter referred to as the AWK book.) __mawk__ conforms to the Posix 1003.2 (draft 11.3) definition of the AWK language which contains a few features not described in the AWK book, and __mawk__ provides a small number of extensions. An AWK program is a sequence of ''pattern {action}'' pairs and function definitions. Short programs are entered on the command line usually enclosed in ' ' to avoid shell interpretation. Longer programs can be read in from a file with the -f option. Data input is read from the list of files on the command line or from standard input when the list is empty. The input is broken into records as determined by the record separator variable, __RS__. Initially, __RS__ = __pattern'' and if it matches, the program text for ''{action}'' is executed. !!OPTIONS -__F__ ''value'' sets the field separator, __FS__, to ''value''. -__f__ ''file'' Program text is read from ''file'' instead of from the command line. Multiple __-f__ options are allowed. -__v__ ''var=value'' assigns ''value'' to program variable ''var''. -- indicates the unambiguous end of options. The above options will be available with any Posix compatible implementation of AWK, and implementation specific options are prefaced with __-W__. __mawk__ provides six: -__W__ version __mawk__ writes its version and copyright to stdout and compiled limits to stderr and exits 0. -__W__ dump writes an assembler like listing of the internal representation of the program to stdout and exits 0 (on successful compilation). -__W__ interactive sets unbuffered writes to stdout and line buffered reads from stdin. Records from stdin are lines regardless of the value of __RS__. -__W__ exec ''file'' Program text is read from ''file'' and this is the last option. Useful on systems that support the __#!__ __ -__W__ sprintf=''num'' adjusts the size of __mawk's__ internal sprintf buffer to ''num'' bytes. More than rare use of this option indicates __mawk__ should be recompiled. -__W__ posix_space forces __mawk__ not to consider 'n' to be space. The short forms __-W__[[vdiesp] are recognized and on some systems __-W__e is mandatory to avoid command line length limitations. !!THE AWK LANGUAGE __1. Program structure__ An AWK program is a sequence of ''pattern {action}'' pairs and user function definitions. A pattern can be: __ BEGIN END __ expression expression , expression One, but not both, of ''pattern {action}'' can be omitted. If ''{action}'' is omitted it is implicitly { print }. If ''pattern'' is omitted, then it is implicitly matched. __BEGIN__ and __END__ patterns require an action. Statements are terminated by newlines, semi-colons or both. Groups of statements such as actions or loop bodies are blocked via { ... } as in C. The last statement in a block doesn't need a terminator. Blank lines have no meaning; an empty statement is terminated with a semi-colon. Long statements can be continued with a backslash, . A statement can be broken without a backslash after a comma, left brace, do__, __else__, the right parenthesis of an __if__, __while__ or __for__ statement, and the right parenthesis of a function definition. A comment starts with # and extends to, but does not include the end of line. The following statements control program flow inside blocks. __if__ ( ''expr'' ) ''statement'' __if__ ( ''expr'' ) ''statement'' __else__ ''statement'' __while__ ( ''expr'' ) ''statement'' __do__ ''statement'' __while__ ( ''expr'' ) __for__ ( ''opt_expr'' ; ''opt_expr'' ; ''opt_expr'' ) ''statement'' __for__ ( ''var'' __in__ ''array'' ) ''statement'' __continue__ __break__ __2. Data types, conversion and comparison__ There are two basic data types, numeric and string. Numeric constants can be integer like -2, decimal like 1.08, or in scientific notation like -1.1e4 or .28E-3. All numbers are represented internally and all computations are done in floating point arithmetic. So for example, the expression 0.2e2 == 20 is true and true is represented as 1.0. String constants are enclosed in double quotes. Strings can be continued across a line by escaping () the newline. The following escape sequences are recognized. \ \ If you escape any other character c, you get c, i.e., __mawk__ ignores the escape. There are really three basic data types; the third is ''number and string'' which has both a numeric value and a string value at the same time. User defined variables come into existence when first referenced and are initialized to ''null'', a number and string value which has numeric value 0 and string value '' The type of an expression is determined by its context and automatic type conversion occurs if needed. For example, to evaluate the statements y = x + 2 ; z = x The value stored in variable y will be typed numeric. If x is not numeric, the value read from x is converted to numeric before it is added to 2 and stored in y. The value stored in variable z will be typed string, and the value of x will be converted to string if necessary and concatenated with atof''(3). A numeric expression is converted to string by replacing ''expr'' with __sprintf(CONVFMT__, ''expr''), unless ''expr'' can be represented on the host machine as an exact integer then it is converted to __sprintf__( __expr''). __Sprintf()__ is an AWK built-in that duplicates the functionality of sprintf(3), and __CONVFMT__ is a built-in variable used for internal conversion from number to string and initialized to __expr'' ''expr''+0 is numeric. To evaluate, ''expr''1 __rel-op__ ''expr''2, if both operands are numeric or number and string then the comparison is numeric; if both operands are string the comparison is string; if one operand is string, the non-string operand is converted and the comparison is string. The result is numeric, 1 or 0. In boolean contexts such as, __if__ ( ''expr'' ) ''statement'', a string expression evaluates true if and only if it is not the empty string '' __3. Regular expressions__ In the AWK language, records, fields and strings are often tested for matching a ''regular expression''. Regular expressions are enclosed in slashes, and '' expr'' ~ /''r''/ is an AWK expression that evaluates to 1 if ''expr'' ''r'', which means a substring of ''expr'' is in the set of strings defined by ''r''. With no match the expression evaluates to 0; replacing ~ with the '' /''r''/ { ''action'' } and __ $0__ ~ /''r''/ { ''action'' } are the same, and for each input record that matches ''r'', ''action'' is executed. In fact, /''r''/ is an AWK expression that is equivalent to (__$0__ ~ /''r''/) anywhere except when on the right side of a match operator or passed as an argument to a built-in function that expects a regular expression argument. AWK uses extended regular expressions as with egrep(1). The regular expression metacharacters, i.e., those with special meaning in regular expressions are ^ $ . [[ ] | ( ) * + ? Regular expressions are built up from characters as follows: ''c'' matches any non-metacharacter ''c''. \''c'' matches a character defined by the same escape sequences used in string constants or the literal character ''c'' if \''c'' is not an escape sequence. . matches any character (including newline). ^ matches the front of a string. $ matches the back of a string. [[c1c2c3...] matches any character in the class c1c2c3... . An interval of characters is denoted c1-c2 inside a class [[...]. [[^c1c2c3...] matches any character not in the class c1c2c3... Regular expressions are built up from other regular expressions as follows: ''r''1''r''2 matches ''r''1 followed immediately by ''r''2 (concatenation). ''r''1 | ''r''2 matches ''r''1 or ''r''2 (alternation). ''r''* matches ''r'' repeated zero or more times. ''r''+ matches ''r'' repeated one or more times. ''r''? matches ''r'' zero or once. (''r'') matches ''r'', providing grouping. The increasing precedence of operators is alternation, concatenation and unary (*, + or ?). For example, /^[[_a-zA-Z][[_a-zA-Z0-9]*$/ and /^[[-+]?([[0-9]+.?|.[[0-9])[[0-9]*([[eE][[-+]?[[0-9]+)?$/ are matched by AWK identifiers and AWK numeric constants respectively. Note that . has to be escaped to be recognized as a decimal point, and that metacharacters are not special inside character classes. Any expression can be used on the right hand side of the ~ or !~ operators or passed to a built-in that expects a regular expression. If needed, it is converted to string, and then interpreted as a regular expression. For example, BEGIN { identifier = prints all lines that start with an AWK identifier. __mawk__ recognizes the empty regular expression, //, which matches the empty string and hence is matched by any string at the front, back and between every character. For example, echo abc | mawk { gsub(//, __4. Records and fields__ Records are read in one at a time, and stored in the ''field'' variable __$0__. The record is split into ''fields'' which are stored in __$1__, __$2__, ..., __$NF__. The built-in variable __NF__ is set to the number of fields, and __NR__ and __FNR__ are incremented by 1. Fields above __$NF__ are set to __ Assignment to __$0__ causes the fields and __NF__ to be recomputed. Assignment to __NF__ or to a field causes __$0__ to be reconstructed by concatenating the __$i's__ separated by __OFS__. Assignment to a field with index greater than __NF__, increases __NF__ and causes __$0__ to be reconstructed. Data input stored in fields is string, unless the entire field has numeric form and then the type is number and string. For example, echo 24 24E | mawk '{ print($1 __$0__ and __$2__ are string and __$1__ is number and string. The first comparison is numeric, the second is string, the third is string (100 is converted to __ __5. Expressions and operators__ The expression syntax is similar to C. Primary expressions are numeric constants, string constants, variables, fields, arrays and function calls. The identifier for a variable, array or function can be a sequence of letters, digits and underscores, that does not start with a digit. Variables are not declared; they exist when first referenced and are initialized to ''null''. New expressions are composed with the following operators in order of increasing precedence. ''assignment'' = += -= *= /= %= ^= ''conditional'' ? : ''logical or'' || ''logical and'' ''array membership'' __ in __''matching'' ~ !~ ''relational'' ''concatenation'' (no explicit operator) ''add ops'' + - ''mul ops'' * / % ''unary'' + - ''logical not'' ! ''exponentiation'' ^ ''inc and dec'' ++ -- (both post and pre) ''field'' $ Assignment, conditional and exponentiation associate right to left; the other operators associate left to right. Any expression can be parenthesized. __6. Arrays__ Awk provides one-dimensional arrays. Array elements are expressed as ''array''[[''expr'']. ''Expr'' is internally converted to string type, so, for example, A[[1] and A[[ ''expr'' __in__ ''array'' evaluates to 1 if ''array''[[''expr''] exists, else to 0. There is a form of the __for__ statement that loops over each index of an array. __ for__ ( ''var'' __in__ ''array'' ) ''statement ''sets ''var'' to each index of ''array'' and executes ''statement''. The order that ''var'' transverses the indices of ''array'' is not defined. The statement, __delete__ ''array''[[''expr''], causes ''array''[[''expr''] not to exist. __mawk__ supports an extension, __delete__ ''array'', which deletes all elements of ''array''. Multidimensional arrays are synthesized with concatenation using the built-in variable __SUBSEP__. ''array''[[''expr''1,''expr''2] is equivalent to ''array''[[''expr''1 __SUBSEP__ ''expr''2]. Testing for a multidimensional element uses a parenthesized index, such as if ( (i, j) in A ) print A[[i, j] __7. Builtin-variables__ The following variables are built-in and initialized before program execution. __ARGC__ number of command line arguments. __ARGV__ array of command line arguments, 0..ARGC-1. __CONVFMT__ format for internal conversion of numbers to string, initially = __ENVIRON__ array indexed by environment variables. An environment string, ''var=value'' is stored as __ENVIRON__[[''var''] = ''value''. __FILENAME__ name of the current input file. __FNR__ current record number in __FILENAME__. __FS__ splits records into fields as a regular expression. __NF__ number of fields in the current record. __NR__ current record number in the total input stream. __OFMT__ format for printing numbers; initially = __OFS__ inserted between fields on output, initially = __ORS__ terminates each record on output, initially = __RLENGTH__ length set by the last call to the built-in function, __match()__. __RS__ input record separator, initially = __RSTART__ index set by the last call to __match()__. __SUBSEP__ used to build multiple array subscripts, initially = __8. Built-in functions__ String functions gsub(''r,s,t'') gsub(''r,s'') Global substitution, every match of regular expression ''r'' in variable ''t'' is replaced by string ''s''. The number of replacements is returned. If ''t'' is omitted, __$0__ is used. An __s'' is replaced by the matched substring of ''t''. '' index(''s,t'') If ''t'' is a substring of ''s'', then the position where ''t'' starts is returned, else 0 is returned. The first character of ''s'' is in position 1. length(''s'') Returns the length of string ''s''. match(''s,r'') Returns the index of the first longest match of regular expression ''r'' in string ''s''. Returns 0 if no match. As a side effect, __RSTART__ is set to the return value. __RLENGTH__ is set to the length of the match or -1 if no match. If the empty string is matched, __RLENGTH__ is set to 0, and 1 is returned if the match is at the front, and length(''s'')+1 is returned if the match is at the back. split(''s,A,r'') split(''s,A'') String ''s'' is split into fields by regular expression ''r'' and the fields are loaded into array ''A''. The number of fields is returned. See section 11 below for more detail. If ''r'' is omitted, __FS__ is used. sprintf(''format,expr-list'') Returns a string constructed from ''expr-list'' according to ''format''. See the description of printf() below. sub(''r,s,t'') sub(''r,s'') Single substitution, same as gsub() except at most one substitution. substr(''s,i,n'') substr(''s,i'') Returns the substring of string ''s'', starting at index ''i'', of length ''n''. If ''n'' is omitted, the suffix of ''s'', starting at ''i'' is returned. tolower(''s'') Returns a copy of ''s'' with all upper case characters converted to lower case. toupper(''s'') Returns a copy of ''s'' with all lower case characters converted to upper case. Arithmetic functions atan2(''y,x'') Arctan of ''y''/''x'' between - and . cos(''x'') Cosine function, ''x'' in radians. exp(''x'') Exponential function. int(''x'') Returns ''x'' truncated towards zero. log(''x'') Natural logarithm. rand() Returns a random number between zero and one. sin(''x'') Sine function, ''x'' in radians. sqrt(''x'') Returns square root of ''x''. srand(''expr'') srand() Seeds the random number generator, using the clock if ''expr'' is omitted, and returns the value of the previous seed. __mawk__ seeds the random number generator from the clock at startup so there is no real need to call srand(). Srand(''expr'') is useful for repeating pseudo random sequences. __9. Input and output__ There are two output statements, __print__ and __printf__. print writes __$0 ORS__ to standard output. print ''expr''1, ''expr''2, ..., ''expr''n writes ''expr''1 __OFS__ ''expr''2 __OFS__ ... ''expr''n __ORS__ to standard output. Numeric expressions are converted to string with __OFMT__. printf ''format, expr-list'' duplicates the printf C library function writing to standard output. The complete ANSI C format specifications are recognized with conversions %c, %d, %e, %E, %f, %g, %G, %i, %o, %s, %u, %x, %X and %%, and conversion qualifiers h and l. The argument list to print or printf can optionally be enclosed in parentheses. Print formats numbers using __OFMT__ or __file'', ''file'' or | ''command'' to the end of the print statement. Redirection opens ''file'' or ''command'' only once, subsequent redirections append to the already open stream. By convention, __mawk__ associates the filename __mawk__ also associates __ The input function __getline__ has the following variations. getline reads into __$0__, updates the fields, __NF__, __NR__ and __FNR__. getline file'' reads into __$0__ from ''file'', updates the fields and __NF__. getline ''var'' reads the next record into ''var'', updates __NR__ and __FNR__. getline ''var'' ''file'' reads the next record of ''file'' into ''var''. ''command'' | getline pipes a record from ''command'' into __$0__ and updates the fields and __NF__. ''command'' | getline ''var'' pipes a record from ''command'' into ''var''. Getline returns 0 on end-of-file, -1 on error, otherwise 1. Commands on the end of pipes are executed by /bin/sh. The function __close__(''expr'') closes the file or pipe associated with ''expr''. Close returns 0 if ''expr'' is an open file, the exit status if ''expr'' is a piped command, and -1 otherwise. Close is used to reread a file or command, make sure the other end of an output pipe is finished or conserve file resources. The function __fflush__(''expr'') flushes the output file or pipe associated with ''expr''. Fflush returns 0 if ''expr'' is an open output stream else -1. Fflush without an argument flushes stdout. Fflush with an empty argument ( '' The function __system__(''expr'') uses /bin/sh to execute ''expr'' and returns the exit status of the command ''expr''. Changes made to the __ENVIRON__ array are not passed to commands executed with __system__ or pipes. __10. User defined functions__ The syntax for a user defined function is __ function__ name( ''args'' ) { ''statements'' } The function body can contain a return statement __ return__ ''opt_expr ''A return statement is not required. Function calls may be nested or recursive. Functions are passed expressions by value and arrays by reference. Extra arguments serve as local variables and are initialized to ''null''. For example, csplit(''s,A'') puts each character of ''s'' into array ''A'' and returns the length of ''s''. function csplit(s, A, n, i) { n = length(s) for( i = 1 ; i Putting extra space between passed arguments and local variables is conventional. Functions can be referenced before they are defined, but the function name and the '(' of the arguments must touch to avoid confusion with concatenation. __11. Splitting strings, records and files__ Awk programs use the same algorithm to split strings into arrays with split(), and records into fields on __FS__. __mawk__ uses essentially the same algorithm to split files into records on __RS__. Split(''expr,A,sep'') works as follows: (1) If ''sep'' is omitted, it is replaced by __FS__. ''Sep'' can be an expression or regular expression. If it is an expression of non-string type, it is converted to string. (2) If ''sep'' = ''expr'', and ''sep'' becomes ''mawk__ defines __sep'' is treated as a regular expression, except that meta-characters are ignored for a string of length 1, e.g., split(x, A, '' (3) If ''expr'' is not string, it is converted to string. If ''expr'' is then the empty string ''A'' is set empty. Otherwise, all non-overlapping, non-null and longest matches of ''sep'' in ''expr'', separate ''expr'' into fields which are loaded into ''A''. The fields are placed in A[[1], A[[2], ..., A[[n] and split() returns n, the number of fields which is the number of matches plus one. Data placed in ''A'' that looks numeric is typed number and string. Splitting records into fields works the same except the pieces are loaded into __$1__, __$2__,..., __$NF__. If __$0__ is empty, __NF__ is set to 0 and all __$i__ to __ __mawk__ splits files into records by the same algorithm, but with the slight difference that __RS__ is really a terminator instead of a separator. (__ORS__ is really a terminator too). E.g., if __FS__ = __$0__ = __NF__ = 3 and __$1__ = __$2__ = __$3__ = __RS__ = __ __RS__ = __ If __FS__ = __mawk__ breaks the record into individual characters, and, similarly, split(''s,A,'' ''s'' into ''A''. __12. Multi-line records__ Since __mawk__ interprets __RS__ as a regular expression, multi-line records are easy. Setting __RS__ = __FS__ = __ For example, if a file is RS__ = __FS__ = __FS__ = __FS__ = __ If you want lines with spaces or tabs to be considered blank, set __RS__ = __RS__ = __RS__ = __RS__ = __FS__. __mawk__ does not support this convention, because defining __ Most of the time when you change __RS__ for multi-line records, you will also want to change __ORS__ to __ __13. Program execution__ This section describes the order of program execution. First __ARGC__ is set to the total number of command line arguments passed to the execution phase of the program. __ARGV[[0]__ is set the name of the AWK interpreter and __ARGV[[1]__ ... __ARGV[[ARGC-1]__ holds the remaining command line arguments exclusive of options and program source. For example with mawk -f prog v=1 A t=hello B __ARGC__ = 5 with __ARGV[[0]__ = __ARGV[[1]__ = __ARGV[[2]__ = __ARGV[[3]__ = __ARGV[[4]__ = __ Next, each __BEGIN__ block is executed in order. If the program consists entirely of __BEGIN__ blocks, then execution terminates, else an input stream is opened and execution continues. If __ARGC__ equals 1, the input stream is set to stdin, else the command line arguments __ARGV[[1]__ ... __ARGV[[ARGC-1]__ are examined for a file argument. The command line arguments divide into three sets: file arguments, assignment arguments and empty strings var''=''string''. When an __ARGV[[i]__ is examined as a possible file argument, if it is empty it is skipped; if it is an assignment argument, the assignment to ''var'' takes place and __i__ skips to the next argument; else __ARGV[[i]__ is opened for input. If it fails to open, execution terminates with exit code 2. If no command line argument is a file argument, then input comes from stdin. Getline in a __BEGIN__ action opens input. __ Once an input stream is open, each input record is tested against each ''pattern'', and if it matches, the associated ''action'' is executed. An expression pattern matches if it is boolean true (see the end of section 2). A __BEGIN__ pattern matches before any input has been read, and an __END__ pattern matches after all input has been read. A range pattern, ''expr''1,''expr''2 , matches every record between the match of ''expr''1 and the match ''expr''2 inclusively. When end of file occurs on the input stream, the remaining command line arguments are examined for a file argument, and if there is one it is opened, else the __END__ ''pattern'' is considered matched and all __END__ ''actions'' are executed. In the example, the assignment v=1 takes place after the __BEGIN__ ''actions'' are executed, and the data placed in v is typed number and string. Input is then read from file A. On end of file A, t is set to the string ''END__ ''actions'' are executed. Program flow at the ''pattern {action}'' level can be changed with the __ next exit__ '' opt_expr ''statements. A __next__ statement causes the next input record to be read and pattern testing to restart with the first ''pattern {action}'' pair in the program. An __exit__ statement causes immediate execution of the __END__ actions or program termination if there are none or if the __exit__ occurs in an __END__ action. The ''opt_expr'' sets the exit value of the program unless overridden by a later __exit__ or subsequent error. !!EXAMPLES 1. emulate cat. { print } 2. emulate wc. { chars += length($0) + 1 # add one for the n words += NF } END{ print NR, words, chars } 3. count the number of unique 4. sum the second field of every record based on the first field. $1 ~ /credit|gain/ { sum += $2 } $1 ~ /debit|loss/ { sum -= $2 } END { print sum } 5. sort a file, comparing as string { line[[NR] = $0 !!COMPATIBILITY ISSUES The Posix 1003.2(draft 11.3) definition of the AWK language is AWK as described in the AWK book with a few extensions that appeared in SystemVR4 nawk. The extensions are: New functions: toupper() and tolower(). New variables: ENVIRON[[] and CONVFMT. ANSI C conversion specifications for printf() and sprintf(). New command options: -v var=value, multiple -f options and implementation options as arguments to -W. Posix AWK is oriented to operate on files a line at a time. __RS__ can be changed from __RS__ = __RS__ = __FS__. __mawk__, on the other hand, allows __RS__ to be a regular expression. When __FS__ always determines fields. Removing the line at a time paradigm can make some programs simpler and can often improve performance. For example, redoing example 3 from above, BEGIN { RS = counts the number of unique words by making each word a record. On moderate size files, __mawk__ executes twice as fast, because of the simplified inner loop. The following program replaces each comment by a single space in a C program file, BEGIN { RS = Buffering one record is needed to avoid terminating the last record with a space. With __mawk__, the following are all equivalent, x ~ /a+b/ x ~ The strings get scanned twice, once as string and once as regular expression. On the string scan, __mawk__ ignores the escape on non-escape characters while the AWK book advocates ''c'' be recognized as ''c'' which necessitates the double escaping of meta-characters in strings. Posix explicitly declines to define the behavior which passively forces programs that must run under a variety of awks to use the more portable but less readable, double escape. Posix AWK does not recognize mawk__ limits the number of digits that follows x to two as the current implementation only supports 8 bit characters. The built-in __fflush__ first appeared in a recent (1993) AT __delete__ ''array'' is not part of the posix standard. Posix explicitly leaves the behavior of __FS__ = __ Finally, here is how __mawk__ handles exceptional cases not discussed in the AWK book or the Posix draft. It is unsafe to assume consistency across awks and safe to skip to the next section. substr(s, i, n) returns the characters of s in the intersection of the closed interval [[1, length(s)] and the half-open interval [[i, i+n). When this intersection is empty, the empty string is returned; so substr( Every string, including the empty string, matches the empty string at the front so, s ~ // and s ~ RLENGTH__ to 0. index(s, t) is always the same as match(s, t1) where t1 is the same as t with metacharacters escaped. Hence consistency with match requires that index(s, If getline encounters end of file, getline var, leaves var unchanged. Similarly, on entry to the __END__ actions, __$0__, the fields and __NF__ have their value unaltered from the last record. !!SEE ALSO egrep(1) CommaSeparatedVector Aho, Kernighan and Weinberger, ''The AWK Programming Language'', Addison-Wesley Publishing, 1988, (the AWK book), defines the language, opening with a tutorial and advancing to many interesting programs that delve into issues of software design and analysis relevant to programming in any language. ''The GAWK Manual'', The FreeSoftwareFoundation, 1991, is a tutorial and language reference that does not attempt the depth of the AWK book and assumes the reader may be a novice programmer. The section on AWK arrays is excellent. It also discusses [POSIX] requirements for AWK. !!BUGS __mawk__ cannot handle ascii NUL 0 in the source or data files. You can output NUL using printf with %c, and any other 8 bit character is acceptable input. __mawk__ implements printf(3) and sprintf(3) using the C library functions, printf and sprintf, so full ANSI compatibility requires an [ANSI] [C] library. In practice this means the h conversion qualifier may not be available. Also __mawk__ inherits any bugs or limitations of the library functions. Implementors of the AWK language have shown a consistent lack of imagination when naming their programs. !!AUTHOR Mike Brennan (brennan@whidbey.com). ----
16 pages link to
awk(1)
:
AWK
lex(1)
flex(1)
flex++(1)
Man1a
colrm(1)
UnixWay
sed(1)
lsof(8)
BrianKernighan
MeetingTopics.2002
makeindex(1)
ThingsToDoWithYourLinuxBox
TextUtilities
RegularExpression
POSIX
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.