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 . . . [[variable]] named by the left [[operand]]: == Assignment of variables == The following examples show . . . the use of the equals sign for the assignment of [[variable]]s: {{{ fruit = "apple" # . . . assign a string to a variable count = 5 # assign a . . .
1K - last updated 2010-11-28 18:17 UTC by markhobley
AwkGuide
** Work in Progress ** {{{ import from Mark Hobley's wiki }}} <toc> ---- == Overview * [[Overview]] . . . * [[associative container|array]]s * [[assign]]ment * [[associative container]]s * [[backslash]] . . . * [[comparative operator]]s * [[compound assignment operator]]s * [[concatenation]] * conditional . . . loop]s * [[value]]s * [[variable]]s * variable [[assign]]ment * [[variable name]]s * [[variable substitution]] . . .
4K - last updated 2011-08-14 15:57 UTC by markhobley
AwkTips
<toc> ---- == Be idiomatic! In this paragraph, we give some hints on how to write more idiomatic . . . line awk '$0 = NR" "$0' # prepends line numbers (assignments are valid in conditions) awk '!a[$0]++' . . . code relies on the fact that GNU awk supports assigning a regular expression to RS (the standard . . . has leading spaces or not; * for some reason, assigning that regex to FS produces unexpected results . . . strings and numbers. Internally, awk does not assign a fixed type to the variables; they are literally . . .
31K - last updated 2009-03-24 16:54 UTC by waldner
Backreferences
The usual (and correct) answer for backreferences in awk (for example, the answer you can get on #awk . . . you can use the possibility to assign a regexp to RS to "pull out" substrings from . . .
3K - last updated 2010-12-30 06:53 UTC by ppp089210039107.dsl.hol.gr
comparative operator
The comparative operators are used to determine equality or inequality or otherwise make comparisons . . . programming mistake is to attempt to use the assignment operator as a comparison within an expression: . . .
3K - last updated 2013-02-24 17:38 UTC by markhobley
compound assignment operator
The *compound assignment operators* (also called *combination assignment operators*) provide a more concise . . . === Care should be taken when compound assignment operators are used within an [[expression]]. . . . Without [[parentheses]], the compound assignment operators may have a lower [[precedence]] . . . {{{ a = b + c += 2 ; # Syntax error: you cannot assign to 'b + c'. This is equivalent to a = (b + c) . . . it to b }}} === There are no logical compound assignment operators in awk === The awk extraction . . .
2K - last updated 2011-03-27 09:46 UTC by markhobley
division
== Quotient Division == The [[slash]] symbol can be used as the division [[operator]] to produce the . . . answer = 18 / 3 # 6 == Division Combination Assignment Operator == The division [[combination assignment . . .
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]]: . . . behaviour]], or a [[fatal error]] will occur. == Assignment to dollarint variables == It is possible . . . in the current [[record]] by making an [[assign]]ment to the dollarint [[special variable]]: . . .
3K - last updated 2011-06-25 05:28 UTC by pgas
environment
The ENVIRON [[associative container]] contains the values of the current environment. This enables an . . . [[associative container]] can be changed by [[assignment]]. However, this does not affect the environment . . .
1K - last updated 2011-06-07 01:05 UTC by markhobley
exponent
==Warning! The use of [[gawkism]]s will prevent the script from running correctly on systems that use . . . than multiplication }}} **Exponent Combination Assignment Operator** *The exponent [[combination assignment . . .
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. . . . for file input and output * supports multiple [[assignment]]s from a single statement * the [[hashbang]] . . .
1K - last updated 2011-05-27 15:33 UTC by markhobley
field reference
== The field reference operator == The [[dollar]] symbol acts as a unary *field reference operator* and . . . or a [[fatal error]] will occur. === Assignment to referenced field === It is possible to . . . in the current [[record]] by making an [[assign]]ment to the referenced field: {{{ { $2 = 23 . . .
2K - last updated 2011-06-28 09:12 UTC by markhobley
FIXES
[[FIXES]] revised: . . . \\ fixed order of evaluation of commandline assignments to match what the\\ book . . . -v x=1 ... for immediate commandline variable assignment;\\ done . . . a separate -v for each assignment.\\ \\ FILENAME is now defined in the BEGIN . . .
6K - last updated 2014-01-15 23:17 UTC by g0ph3r
FS
= Field Separator = The [[special variable]] FS is a field separator that is used to determine how [[awk]] . . . record. == The field separator can be changed by assignment == The field separator can be changed by . . . [[assign]]ment like any other [[variable]]. Note that . . .
5K - last updated 2013-02-19 21:45 UTC by markhobley
LastField
awk performs a number of actions automatically when it parses lines: it updates the variable NF, which . . . field before the last one }}} (Note that you can assign these fields, but that's another story See the . . .
2K - last updated 2009-02-05 22:43 UTC by firebush.stsci.edu
modulus
The [[dyadic]] modulus [[operator]], represented by a [[percent]] sign is used to return the remainder . . . print -13 % 7 # -6 == Modulus Combination Assignment Operator == The modulus [[compound assignment . . .
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 . . . = 3 * 4 # 12 === Multiplication Combination Assignment Operator === The multiplication compound . . . assignment operator represented by a starequals digraph, . . .
1K - last updated 2011-04-17 06:32 UTC by markhobley
operator
The [[awk]] programming language provides a series of *operators* that allow [[value]]s and [[variable]]s . . . the number of [[operand]]s that they utilize. == assignment operator As within most other programming . . . sign''' acts as a [[dyadic]] operator, [[assign]]ing the value of the [[expression]] of the . . . arrow operator * [[arrow operator]] == compound assignment operators * [[compound assignment operator]]s . . .
3K - last updated 2011-05-24 22:19 UTC by markhobley
precedence
The [[awk]] programming language uses rules of *precedence* to determine the order in which [[operator]]s . . . of 8 or 9, depending on whether or not the [[assignment]] in [[parentheses]] affects the value outside. . . .
7K - last updated 2013-04-11 06:58 UTC by markhobley
PrimeNumberSieve
This is the standard sieve of Eratosthenes implemented in portable awk. The running time of the bare . . . only arrays and numbered fields offer O(1) assignment as well; and of those two, numbered fields . . .
4K - last updated 2008-06-19 05:56 UTC by gnomon
RangeOfFields
Printing a range of fields - all fields but the first, for examples, or fields 3 through 8 - is a surprisingly . . . place. This means that you can, for example, assign an empty string to the fields preceding and . . . 1), $i) + length($i) - 1; } } # do processing, reassignments, whatever here { $2 = "new"; } # print . . .
10K - last updated 2015-09-08 09:52 UTC by pgas
RS
= Record Separator = The [[special variable]] RS is a record separator that is used to determine how . . . 3 }}} == The record separator can be changed by assignment or command line switch == The record separator . . . can be changed by assignment like any other variable. This is often done . . .
3K - last updated 2013-02-19 23:11 UTC by markhobley
symbol
| *Symbol* | *Name* | *Purpose* | !! | [[pling]] | logical NOT | " | [[doublequote]] | | # | [[hash]] . . . nudge operator | += | addition compound assignment operator | -= | subtraction compound assignment . . . operator | *= | multiplication compound assignment operator | /= | division compound assignment . . . operator | ^= | exponent compound assignment operator | %= | modulus compound assignment . . .
2K - last updated 2013-02-19 14:26 UTC by markhobley
truth
== Boolean Truth == A **boolean [[expression]]** has only two outcomes: **true** or **false**. In [[awk]], . . . Taking zero from a variable If a zero value is assigned to a variable, it may be treated as a non . . . = "00" True! }}} However, if the variable was assigned in numeric context (without the quotes), it . . . even if it contains 0 var = "" }}} ==== if you assign 0 to a var Then var is false, no problem === . . .
3K - last updated 2013-02-20 17:34 UTC by markhobley
variable
A '''variable''' is a symbolic name associated with a [[value]]. A variable acts as a container and the . . . directly print "hello " name; # concatenate, assign to 'newstr' and print that newstr = "hello " . . .
3K - last updated 2012-04-22 11:42 UTC by unregistered
WartAndWishList
Awk is a wonderful language! That said, there are a few annoying bits... == The Good * well-documented . . . * Some strings are assignable and some are not. This is probably because . . . non-assignable strings stored as simple {ref-string, start, . . . Please, could somebody give an example for non-assignable strings?)// * There is no portable built-in . . . * There is no way of declaring an array without assigning a value to a key. This isn't a semantic problem, . . .
7K - last updated 2009-04-13 18:39 UTC by goedel
26 pages found.