AllAboutGetline

//Editor's notes: The article was originally posted on the comp.lang.awk newsgroup, and can still be . . . ambiguous if expression contains unparenthesized **operator**s other than "$"; for example, {{{ awk getline . . . file }}} is ambiguous because the concatenation **operator** is not parenthesized. You should write it . . .

16K - last updated 2009-02-15 22:14 UTC by waldner

arithmetic

The [[awk]] programming language provides a set of [[dyadic]] arithmetic **operator**s for performing basic . . . on [[integer]] and [[floating point]] values. | ***Operator*** | *Description* | + | [[addition]] | - | . . . language does not provide an exponent **operator** == Traditionally, the [[awk]] programming . . . language does not provide an [[exponent]] **operator**. == The backslash symbol may not be used for . . . [[backslash]] symbol as an [[integer division]] **operator**. ---- [[Calculations involving integers may . . .

1K - last updated 2011-05-24 22:16 UTC by markhobley

arithmetic operator

{{delete}} . . .

1K - last updated 2011-05-24 22:18 UTC by markhobley

assign

== The assignment **operator** == In [[awk]], as with most other programming languages, the *equals sign* . . . acts as a [[dyadic]] *assignment [[**operator**]]* assigning the value of the [[expression]] . . .

1K - last updated 2010-11-28 18:17 UTC by markhobley

AwkDc

This is an awk implementation of the [http://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html|dc] . . . (val ~ /^ARRAY: /) } # }}} ----- # PRIMITIVE **OPERATOR** FUNCTIONS {{{ ---- # -- printing commands . . . -- miscellaneous # ! # # # :r # ;r # }}} ----- # **OPERATOR** DISPATCH TABLE {{{ --------- function _dc_dispatch(stk, . . . proper # parser, except perhaps by bypassing the **operator** # dispatch table and stuffing string values . . .

12K - last updated 2008-07-17 14:47 UTC by gnomon

AwkGuide

** Work in Progress ** {{{ import from Mark Hobley's wiki }}} <toc> ---- == Overview * [[Overview]] . . . * [[backslash]] * [[BEGIN]] * [[bitwise **operator**]]s * [[block]]s * [[brace]]s * [[branch]]es . . . line parameter]]s * [[comment]]s * [[comparative **operator**]]s * [[compound assignment **operator**]]s * [[concatenation]] . . . * [[field]]s * [[field reference]] **operator** * [[FS|field separator]] * [[file]] handling . . . function]]s * [[mistake]]s * [[modulus]] **operator** * [[multiline]] records * [[multiplication]] . . .

4K - last updated 2011-08-14 15:57 UTC by markhobley

AwkOnWindowsHowto

AwkOnWindowsHowto\\ rough cut - needs edit {{{ 3) awk command line switches/usage from a win32 cmd.exe . . . varname, SYMTAB[varname]) The `**' and `**=' **operator**s are valid instead of ^ #: system() returns . . .

3K - last updated 2010-10-24 07:44 UTC by g0pher

bitwise operator

Traditional [[awk]] implementations do not support bitwise **operator**s. == Function Gawkisms == Bitwise . . .

1K - last updated 2011-03-07 19:55 UTC by markhobley

branch

A branch is a [[control structure]] that allow a particular section of code to be conditionally executed . . . including: [[if]], [[else]] === Using logical **operator**s === The [[awk]] extraction and reporting . . . to perform conditional branching using logical **operator**s. . . .

1K - last updated 2011-04-17 06:37 UTC by markhobley

comparative operator

The comparative **operator**s are used to determine equality or inequality or otherwise make comparisons . . . evaluates to zero. The following comparative [[**operator**]]s are supported by [[awk]]: | == | [[equality]] . . . | [[greaterthanorequal]] | ?: | [[ternary]] **operator** == String comparison In awk, the comparative . . . **operator**s can be used to compare strings for lexical . . . equivalence or ordering. The string matching **operator**s are case sensitive and the behaviour of the . . .

3K - last updated 2013-02-24 17:38 UTC by markhobley

compound assignment operator

The *compound assignment **operator**s* (also called *combination assignment **operator**s*) provide a more concise . . . | !/= | [[division]] | %= | [[modulus]] === **Operator** precedence === Care should be taken when compound . . . assignment **operator**s are used within an [[expression]]. Without . . . [[parentheses]], the compound assignment **operator**s may have a lower [[precedence]] than the . . . other **operator**s around them, causing unexpected results to . . .

2K - last updated 2011-03-27 09:46 UTC by markhobley

concatenation

== The awk programming language does not have an explicit concatenation **operator** == The awk programming . . . language does not have an explicit concatenation **operator**. Concatenation of [[string]]s in awk is achieved . . .

1K - last updated 2011-06-25 05:13 UTC by pgas

division

== Quotient Division == The [[slash]] symbol can be used as the division [[**operator**]] to produce the . . . = 18 / 3 # 6 == Division Combination Assignment **Operator** == The division [[combination assignment **operator**]] . . . of a [[backslash]] symbol as an integer division **operator**. However, the [[int]] function can be used . . .

2K - last updated 2011-03-20 07:07 UTC by markhobley

dollarint

A [[dollar]] sign and followed by an [[integer]] are used to refer to [[field]]s within the current [[record]]: . . . exactly true, in fact $ is the field reference **operator** and 3 is just a number that tells awk you . . .

3K - last updated 2011-06-25 05:28 UTC by pgas

dot

== The dot symbol == === The dot symbol as a regular expression **operator** === The [[dot]] symbol can be . . . used as a [[regular expression **operator**]] to match any single character. A [[newline]] . . . character can also be matched by the dot symbol **operator**. . . .

1K - last updated 2010-11-11 23:41 UTC by markhobley

enumeration

The [[awk]] extraction and reporting language does not directly support enumeration. However, it is possible . . . by using a [[variable]] and [[nudge]] **operator** combination. In the following example we enumerate . . .

1K - last updated 2011-05-27 15:28 UTC by markhobley

exponent

==Warning! The use of [[gawkism]]s will prevent the script from running correctly on systems that use . . . [[awk]] interpreter. **The doublestar exponent **operator** is not available in traditional implementations** . . . do not provide an exponent [[arithmetic]] **operator**. The [[doublestar]] symbol used here for [[arithmetic]] . . . gawkism acts as a dyadic exponent [[**operator**]]. It returns the [[value]] given as a left . . . the power of 3) }}} **Precedence** *The exponent **operator** gawkism has a higher [[precedence]] than all . . .

2K - last updated 2012-03-20 07:33 UTC by g0pher

Features of awk

The [[awk]] utility: * treats lines of a text as database records, which can be divided into fields. . . . data. * makes use of mathematical and string [[**operator**]]s. * uses common programming constructs, . . .

1K - last updated 2011-05-27 15:33 UTC by markhobley

field

In [[awk]] all [[input]] is separated into [[record]]s and each [[record]] is further divided into fields. . . . field can be referenced by using [[dollarint]] **operator**. {{{ awk { print $3 } # output field number . . .

1K - last updated 2011-06-25 05:31 UTC by pgas

field reference

== The field reference **operator** == The [[dollar]] symbol acts as a unary *field reference **operator*** and . . . takes [[precedence]] over the field reference **operator**: {{{ print $(3 + 2) # output field number . . .

2K - last updated 2011-06-28 09:12 UTC by markhobley

FieldReference

$ is the "field reference" **operator** in AWK. It references the field in the current input record given . . . {{{ # print the first field using the '$' **operator** and a constant. print $1; # same but with . . .

1K - last updated 2009-01-03 01:51 UTC by fcr

gawkism

Gawkisms are non portable syntax components that do not work with some awk implementations. The use of . . . * delete array * [[ERRNO]] * [[exponent]] **operator** * [[FIELDWIDTHS]] * [[gensub]] function * . . . * [[or]] (bitwise function) * [[pipeand]] **operator** * [[PROCINFO]] * [[RS]] can be a [[regular . . .

2K - last updated 2011-05-19 22:29 UTC by markhobley

LastField

awk performs a number of actions automatically when it parses lines: it updates the variable NF, which . . . exactly true, in fact $ is the field reference **operator** and 1 is just a number that tells awk you . . .

2K - last updated 2009-02-05 22:43 UTC by firebush.stsci.edu

logical operator

In [[awk]], *logical **operator**s* are used to perform [[boolean]] operations, and a return a value of [true] . . . depending on the values of the [operand]s. | ***Operator*** | *Symbol* | *Description* | [[and]] | [[doubleampersand . . . [[awk]] does not provide a logical [[xor]] **operator** == Results of Logical Operations * [[Results . . . of Logical Operations]] The [[logical]] **operator**s return a [[boolean]] value of 0 for [[false]], . . . }}} == Precedence * [[Precedence of logical **operator**s]] The unary [[NOT]] **operator** has a higher . . .

3K - last updated 2009-01-02 11:13 UTC by pgas

LoopOnFields

Fields are numbered from 1 to NF, so you can easily use a for loop, and the derefence **operator**, for instance . . .

1K - last updated 2009-03-17 21:09 UTC by waldner

modulus

The [[dyadic]] modulus [[**operator**]], represented by a [[percent]] sign is used to return the remainder . . . divided by 4) == Negative Numbers == The modulus **operator** may be used with negative numbers: print -13 . . . % 7 # -6 == Modulus Combination Assignment **Operator** == The modulus [[compound assignment **operator**]] . . .

1K - last updated 2011-06-07 00:41 UTC by markhobley

multiplication

== Multiplication **Operator** == The multiplication **operator** represented by the star symbol, is used as . . . a dyadic **operator** used to return the calculated product of two . . . 4 # 12 === Multiplication Combination Assignment **Operator** === The multiplication compound assignment . . . **operator** represented by a starequals digraph, can also . . .

1K - last updated 2011-04-17 06:32 UTC by markhobley

nudge operator

The *nudge **operator**s* can be used to [[increment]] or [[decrement]] the value of their [[operand]]s, . . . depending on which [[**operator**]] is used. The *increment **operator*** (nudge . . . by a [[plusplus]] symbol and the *decrement **operator*** (nudge down), is represented by a [[doubledash]] . . . symbol. The nudge [[**operator**]]s modify their [[operand]]s, so the [[operand]]s . . . # increment number-- # decrement }}} == Nudge **operator**s can exhibit pre-nudge or post-nudge behaviour . . .

3K - last updated 2011-03-20 13:18 UTC by markhobley

number

== _Numbers can be expressed as integers or floating point values_ In [[awk]], numbers can be expressed . . . in awk must be prefixed with a minus numbersign **operator**: number = -5 It is also possible to use the . . . plus symbol as a unary numbersign **operator** to prefix positive numbers. However, this . . .

1K - last updated 2011-03-06 22:33 UTC by markhobley

number sign operators

== _Number sign **operator**s_ === _Negative numbers_ The *minus symbol* may be used as a [[unary]] **operator** . . . The *plus symbol* may be used as a [unary] **operator** in [[positive]] number representation. This . . .

1K - last updated 2011-02-28 12:39 UTC by pgas

numeric strings

Numeric strings obtained from the input source, will be treated as numeric values, when compared with . . . and compared lexically. The behaviour of the **operator**s when one value is considered to be numeric . . .

5K - last updated 2013-02-24 17:40 UTC by markhobley

operator

The [[awk]] programming language provides a series of ***operator**s* that allow [[value]]s and [[variable]]s . . . to be compared, evaluated or manipulated. These **operator**s can combined together with [[value]]s and . . . [[variable]]s to make [[expression]]s. The **operator**s may take [[unary]], [[dyadic]] or [[ternary]] . . . of [[operand]]s that they utilize. == assignment **operator** As within most other programming languages, . . . the '''equals sign''' acts as a [[dyadic]] **operator**, [[assign]]ing the value of the [[expression]] . . .

3K - last updated 2011-05-24 22:19 UTC by markhobley

output

== output == === standard output === === output to files === The [[awk]] programming language uses a . . . to a file is achieved by using [[redirection]] **operator**s. Once [[redirection]] has been defined, the . . .

1K - last updated 2010-11-16 00:44 UTC by markhobley

precedence

The [[awk]] programming language uses rules of *precedence* to determine the order in which [[**operator**]]s . . . are used during evaluation. The order that [[**operator**]]s are evaluated within an [[expression]] . . . are predetermined by the intepreter and the [[**operator**]]s with the highest priority are evaluated . . . It is possible to change the order in which [[**operator**]]s within an [[expression]] are evaluated . . . before the multiplication }}} == _Groups of **operator**s or functions within parentheses have the . . .

7K - last updated 2013-04-11 06:58 UTC by markhobley

PrintASingleQuote

This question gets asked often enough that it deserves its own answer. This common question doesn't actually . . . string syntax and the "$" field reference **operator**. ==== Hex Escapes: Bad Juju Frustratingly, . . .

5K - last updated 2015-07-05 09:45 UTC by pitman

RangeOfFields

Printing a range of fields - all fields but the first, for examples, or fields 3 through 8 - is a surprisingly . . . using the appropriate values for the repetition **operator**. Keep in mind that the {n} repetition **operator** . . . POSIX compatibility, which includes repetition **operator**s). If FS is not the default, but it's still . . .

10K - last updated 2015-09-08 09:52 UTC by pgas

redirection

The awk scripting language provides support for redirection via the greaterthan, doublebeak and pipe . . . greaterthan symbol acts as an output redirection **operator** allowing output from a function to be written . . .

2K - last updated 2011-06-25 05:12 UTC by pgas

redirection operator

[[DeletedPage]] . . .

1K - last updated 2011-06-02 22:49 UTC by markhobley

regular expression

<toc> ---- * [[Overview of regular expressions]] * [[regular expression **operator**]]s * [[Simple . . .

1K - last updated 2008-12-30 12:12 UTC by Mark Hobley

regular expression operator

The [[awk]] programming language provides a set of *regular expression **operator**s* that have special meanings . . . expression]]s. == _Regular Expression Binding **Operator**s_ The *regular expression binding **operator*** . . . by combining the regular expression binding **operator** with a logical not **operator**: {{{ if (text . . . { print "Match not found" } }}} == _A binding **operator** is not required when a regular expression . . . is used as a pattern within a rule_ A binding **operator** is not required if a regular expression is . . .

2K - last updated 2013-02-19 14:06 UTC by markhobley

RepeatAString

Sometimes it is useful to have something like Perl's 'x' **operator**, which repeats a string N times. This . . .

1K - last updated 2009-03-01 19:15 UTC by h-67-101-152-180.nycmny83.dynamic.covad.net

slash

== Division **Operator** == The slash symbol is used as the division **operator** to produce the [[result]]s . . .

1K - last updated 2011-05-11 15:00 UTC by markhobley

symbol

| *Symbol* | *Name* | *Purpose* | !! | [[pling]] | logical NOT | " | [[doublequote]] | | # | [[hash]] . . . comments | $ | [[dollar]] | field reference **operator** and regular expression anchor | % | [[percent]] . . . | | * | [[asterisk]] | multiplication **operator** and regular expression **operator** | + | [[plus]] . . . | optional positive number prefix, addition **operator** and regular expression **operator** | , | [[comma]] . . . [[hyphen]] | negative number prefix, subtraction **operator**, regular expression range **operator** | . | [[dot]] . . .

2K - last updated 2013-02-19 14:26 UTC by markhobley

tilde

== Substring containment **operator** == The tilde [[symbol]] can be used as a containment **operator** providing . . . a [[regular expression]]: === Non containment **operator** === . . .

1K - last updated 2011-05-19 19:04 UTC by markhobley

WartAndWishList

Awk is a wonderful language! That said, there are a few annoying bits... == The Good * well-documented . . . of it as the {{{string ~ pattern}}} matching **operator**, but it is backward from every other built-in . . .

7K - last updated 2009-04-13 18:39 UTC by goedel

45 pages found.