AA-awk-one-page
http://awk.freeshell.org/AA-awk-one-page\\ 2013-09-19 20:23:02 http://awk.freeshell.org/g0ph3r\\ attempt . . . \\ wiki: http://awk.freeshell.org/?action=index\\ portal: http://awk.info/?var/toc\\ irc . . .
2K - last updated 2013-09-20 06:55 UTC by g0ph3r
action
== Default action == If a [[rule]] does not include an [[action]], then the default action is used. . . . The default action is to output all [[line]]s that matches the . . .
1K - last updated 2011-05-09 22:08 UTC by markhobley
AllAboutGetline
//Editor's notes: The article was originally posted on the comp.lang.awk newsgroup, and can still be . . . had for prior processing in the same condition/action block. **d)** Many of the getline variants above . . . transitions: {{{ awk FNR==1 { ... start of file actions ... } }}} File transitions can occur at getlines, . . . just collect the data within the awk condition/action part after testing for the first file is largely . . .
16K - last updated 2009-02-15 22:14 UTC by waldner
arithmetic
The [[awk]] programming language provides a set of [[dyadic]] arithmetic operators for performing basic . . . | *Description* | + | [[addition]] | - | [[subtraction]] | !* | [[multiplication]] | !/ | [[division]] . . . awk print 6 + 3 # addition print 8 - 3 # subtraction print 6 * 3 # multiplication print 10 / 4 # . . .
1K - last updated 2011-05-24 22:16 UTC by markhobley
awk-glossary
concise glossary of the essential awk - Last edited 2014-08-04 02:26 UTC\\ Contents: . . . http://awk.freeshell.org/?action=index\\ refs: . . .
5K - last updated 2014-08-04 03:23 UTC by y0tta
awk1page
an awk program is a series of //pattern { actions }// statements;\\ ie if the input line matchs pattern . . . then the actions are performed. {{{awk /abc/ { print } }}} would . . . omited pattern matchs every line and an omitted action just prints the line.\\ The special pattern . . . most Extensive list: [[http://awk.freeshell.org/?action=index|AwkChannelWiki: Index of all pages]] . . .
2K - last updated 2012-03-18 22:22 UTC by g0pher
awk Lucent Copyright notice
file FIXES from http://www.cs.princeton.edu/~bwk/btl.mirror/awk.zip ; version 20110810 {{{awk /***** . . . FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, . . .
2K - last updated 2012-08-26 11:45 UTC by g0ph3r
AwkGuide
** Work in Progress ** {{{ import from Mark Hobley's wiki }}} <toc> ---- == Overview * [[Overview]] . . . World * [[Hello World in awk]] == How to awk * [[action]]s * [[arithmetic]] * [[command line parameter|ARGC]] . . .
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 . . . of a program, which is {{{ condition { actions } }}} Our program can clearly be rewritten . . . this form, since both the condition and the action are very clear here: {{{ awk '$0 ~ /pattern/ . . . $0}' }}} Now, let's turn our attention to the action part (what's inside braces). **print $0** is . . . a condition is true, and there are no associated actions, awk performs a default action that is (you . . .
31K - last updated 2009-03-24 16:54 UTC by waldner
BEGIN
== Begin Blocks The [[awk]] programming language allows us to use **begin blocks** and **end blocks** . . . to provide [[startup]] and [[cleanup]] actions within the program. == Execution **Begin blocks** . . . squiggly brace enclosures. There is no default action provided for begin block, so they must contain . . . explicit actions. **Begin blocks** are typically used to initialize . . .
3K - last updated 2013-04-11 14:25 UTC by 92.40.253.171.threembb.co.uk
brace
== Enclosure of actions == In [[awk]], squiggly braces are used as [[enclosure]]s around [[action]]s . . . create a [[block]] of [[statement]]s within an action: . . .
1K - last updated 2010-11-10 22:41 UTC by markhobley
branch
A branch is a [[control structure]] that allow a particular section of code to be conditionally executed . . . Using conditional keywords === The [[awk]] extraction and reporting language provides a variety of . . . === Using logical operators === The [[awk]] extraction and reporting language also provides the facility . . .
1K - last updated 2011-04-17 06:37 UTC by markhobley
CAAN-or-caan
**caan: the comprehensive awk archive network**\\ -or-\\ . . . - topics - toc\\ http://awk.freeshell.org/?action=index\\ ---- **Versions:**\\ bwk-awk: . . .
4K - last updated 2014-05-29 02:01 UTC by g0ph3r
case conversion
The [[awk]] extraction and reporting language provides the toupper and tolower functions for converting . . .
2K - last updated 2011-06-25 05:10 UTC by pgas
case sensitivity
== Indentifier names == The [[awk]] interpreter is lettercase sensitive. This means that [[variable name]]s . . . before attempting to match ==== The [[awk]] extraction and reporting language provides a variety of . . .
1K - last updated 2011-06-25 05:14 UTC by pgas
command line parameter
The [[awk]] extraction and reporting language uses traditional conventions for accessing command line . . .
1K - last updated 2011-06-25 05:49 UTC by pgas
comp.lang.awk FAQ
This material of this faq originates from the comp.lang.awk FAQ that you can find there: * http://www.faqs.org/faqs/computer-lang/awk/faq/ . . . "What is awk"> [[http://awk.freeshell.org/?action=edit;id=What_is_awk| Edit this answer]] ---- . . . "Shells"> [[http://awk.freeshell.org/?action=edit;id=Shells| Edit this answer]] === Environment . . . "EnvVarGeneral"> [[http://awk.freeshell.org/?action=edit;id=EnvVarGeneral| Edit this answer]] === . . . "ShellQuoting"> [[http://awk.freeshell.org/?action=edit;id=ShellQuoting| Edit this answer]] === . . .
8K - last updated 2009-03-04 12:42 UTC by pgas
comp.lang.awk FAQJapanese
This material of this faq originates from the comp.lang.awk FAQ that you can find there: * http://www.faqs.org/faqs/computer-lang/awk/faq/ . . . is awkJapanese"> [[http://awk.freeshell.org/?action=edit;id=What_is_awkJapanese| Edit this answer]] . . . "ShellsJapanese"> [[http://awk.freeshell.org/?action=edit;id=ShellsJapanese| Edit this answer]] === . . . [[http://awk.freeshell.org/?action=edit;id=EnvVarGeneralJapanese| Edit this answer]] . . . [[http://awk.freeshell.org/?action=edit;id=ShellQuotingJapanese| Edit this answer]] . . .
4K - last updated 2008-11-24 09:01 UTC by pgas
ComparingTwoFiles
Sometimes it is useful to compare two files. To do this in awk, the trick is to load the data from the . . . $1 is present in arr, ie in file1, the default action will be executed and the line will be printed. . . .
2K - last updated 2011-08-25 00:35 UTC by steve
compound assignment operator
The *compound assignment operators* (also called *combination assignment operators*) provide a more concise . . . === | += | [[addition]] | !-= | [[subtraction]] | !*= | [[multiplication]] | !/= | [[division]] . . . assignment operators in awk === The awk extraction and reporting language does not provide support . . .
2K - last updated 2011-03-27 09:46 UTC by markhobley
ConcatenationPrecedence
You'd expect `6 -22', but you get `6-22'. It's because the `" " -22' is grouped first, as a substraction . . .
1K - last updated 2008-12-15 12:37 UTC by pgas
ConvertHexToFloatingPoint
This code uses [[gawkism|gawk specific features]], such as the [[http://www.gnu.org/manual/gawk/html_node/Strtonum-Function.html][strtonum]] . . . exponent=or(exponent,tmp) # bits 0-22 are the fraction fraction=and(i2,0x7F) fraction=lshift(fraction,8) . . . fraction=or(fraction,i1) fraction=lshift(fraction,8) . . . fraction=or(fraction,i0) #convert the fraction part into . . . decfrac=0 for(i=22;i>=0;i--) { if( and( fraction , lshift(0x01,i) )) decfrac = decfrac+2^(i-23) . . .
3K - last updated 2010-06-23 19:49 UTC by john b
CookBook
<toc> ---- Just started, the aim of this page is to collect small pieces of code that illustrate . . . "LoopOnFields"> [[http://awk.freeshell.org/?action=edit;id=LoopOnFields| Edit this answer]] ---- . . . "EmptyArray"> [[http://awk.freeshell.org/?action=edit;id=EmptyArray| Edit this answer]] ---- . . . "JoinArray"> [[http://awk.freeshell.org/?action=edit;id=JoinArray| Edit this answer]] ---- == . . . [[http://awk.freeshell.org/?action=edit;id=LastMatchOnLine| Edit this answer]] . . .
1K - last updated 2009-04-14 09:03 UTC by 216.162.199.202
END
The [[awk]] programming language allows us to use **end blocks** to provide [[finishoff]] and [[cleanup]] . . . actions within the program. == Labelling An **end block** . . . input record is read. == End blocks must contain actions There is no default action for end blocks, . . . so end block must contain defined actions. An end block must contain actions. == There . . .
2K - last updated 2011-04-30 22:52 UTC by markhobley
enumeration
The [[awk]] extraction and reporting language does not directly support enumeration. However, it is possible . . .
1K - last updated 2011-05-27 15:28 UTC by markhobley
Frequently Asked Questions
Some entries of this page have been copied from the [[comp.lang.awk_FAQ]]([[http://awk.freeshell.org/comp.lang.awk_FAQ#toc29|Credits]]) . . . "RangeOfFields"> [[http://awk.freeshell.org/?action=edit;id=RangeOfFields| Edit this answer]] ---- . . . "LastField"> [[http://awk.freeshell.org/?action=edit;id=LastField| Edit this answer]] ---- == . . . [[http://awk.freeshell.org/?action=edit;id=PrintingNumbers| Edit this answer]] . . . "EditInPlace"> [[http://awk.freeshell.org/?action=edit;id=EditInPlace| Edit this answer]] ---- . . .
3K - last updated 2015-09-08 08:46 UTC by pgas
g0pher
Notes: [[g0pher]] from [[irc://irc.freenode.net//#awk|#awk channel on freenode]]. *Latest (2012-03-18) . . . Extensive list: [[http://awk.freeshell.org/?action=index|Awk Channel Wiki: Index of all pages]] . . .
2K - last updated 2013-05-28 04:13 UTC by g0ph3r
GoogleSearch
<form action="http://www.google.com/cse" id="cse-search-box"> <div> <input type="hidden" . . .
1K - last updated 2008-06-13 20:44 UTC by pgas
goto
== There is no goto statement or arbitary line labelling facility == The [[awk]] extraction and reporting . . .
1K - last updated 2011-03-26 22:56 UTC by markhobley
Hello World in awk
This example program outputs the words "hello world" to the terminal: {{{ awk # Hello World BEGIN { print . . . any records have been read, providing startup actions within the program. === Squiggly Brackets The . . .
2K - last updated 2010-11-11 19:16 UTC by markhobley
here document
The awk extraction and reporting language does not provide any markup facility for embedding here documents . . .
1K - last updated 2013-02-25 19:28 UTC by markhobley
if
The if [[condition]]al construct allows a [[statement]] or [[block]] of code to be [[condition]]ally . . . endif cocomponents == Note that the [[awk]] extraction and reporting language does not utilize then . . . of a boolean expression. {{{ if (EXPRESSION) ACTION; else ALTERNATIVE ACTION; }}} The following . . .
2K - last updated 2011-09-11 21:43 UTC by 92.40.253.171.threembb.co.uk
include
The [[awk]] extraction and reporting language does not support the use of include files. However, it . . .
2K - last updated 2013-03-30 10:38 UTC by markhobley
LargestAccurateNumber
Most [[awk]] implementations use floating point double precision to represent every kind of numeric value. . . . |=1 bit|=11 bits|=52 bits| |sign|exponent|fraction| Note that it says "fraction" above, not "mantissa". . . . This is because the fraction field is interpreted differently in different . . . If **all** of the exponent bits are 0, the fraction is a 52-bit unsigned integer value. (Unsigned . . . illustrative values |=value|=sign+exponent|=fraction| |2^51|000|8000000000000| |2^52|001|0000000000000| . . .
3K - last updated 2013-04-12 14:52 UTC by ttmrichter
LastField
awk performs a number of actions automatically when it parses lines: it updates the variable NF, which . . .
2K - last updated 2009-02-05 22:43 UTC by firebush.stsci.edu
limitation
== Limitations of awk Some traditional versions of [[awk]] derived from [[Unix]] version 7, may not conform . . . reject this. === Programs containing only BEGIN actions may read and discard input It is a requirement . . . that if a program contains only [[BEGIN]] actions, and contains no instances of [[getline]], . . . then the program should simply execute the actions without reading [[input]]. However, traditional . . .
1K - last updated 2009-04-20 15:50 UTC by Mark Hobley
line orientated
== The awk extraction and reporting language is line orientated == The [[awk]] extraction and reporting . . . language is line orientated. The [[action]] for each [[rule]] must begin on the same line . . . it is possible to have the [[pattern]] and action on separate lines, by using a [[backslash]] . . .
1K - last updated 2011-05-17 23:24 UTC by markhobley
main
== Making the application start up from a main routine == In some languages, a '''main''' function provides . . . when the program starts. The [[awk]] extraction and reporting language is [[datadriven]], so . . .
1K - last updated 2011-07-18 09:57 UTC by markhobley
MultipleFiles
<toc> === Version warning Some of these techniques will require non-ancient versions of awk. === . . . "FileExistence"> [[http://awk.freeshell.org/?action=edit;id=FileExistence| Edit this answer]] === . . . [[http://awk.freeshell.org/?action=edit;id=ReadMultipleFiles| Edit this answer]] . . . "FileName"> [[http://awk.freeshell.org/?action=edit;id=FileName| Edit this answer]] === How . . . "OpeningFiles"> [[http://awk.freeshell.org/?action=edit;id=OpeningFiles| Edit this answer]] === . . .
2K - last updated 2008-11-18 13:38 UTC by pgas
Overview
= Overview of awk = == The primarily purpose of awk is to processing textual data to produce formatted . . . reports == The [[awk]] extraction and reporting language is [[data driven]] and . . . is primarily used for taking [[action]]s against textual data for the purpose of producing . . . of pattern matching and performing associated actions == The [[awk]] utility takes each [[line]] . . . matches the [[input line]], [[awk]] takes the [[action]] associated with the [[pattern]]. If the line . . .
4K - last updated 2011-05-23 23:09 UTC by markhobley
Overview of regular expressions
== What is a regular expression? == A regular expression is a method of representing a string matching . . . across application programs. The [[awk]] extraction and reporting language uses superset of the . . .
2K - last updated 2011-05-17 20:32 UTC by markhobley
PassingVariables
<toc> === Shells <include "Shells"> [[http://awk.freeshell.org/?action=edit;id=Shells| Edit . . . "EnvVarGeneral"> [[http://awk.freeshell.org/?action=edit;id=EnvVarGeneral| Edit this answer]] === . . . "ShellQuoting"> [[http://awk.freeshell.org/?action=edit;id=ShellQuoting| Edit this answer]] === . . . "ENVIRON"> [[http://awk.freeshell.org/?action=edit;id=ENVIRON| Edit this answer]] === exporting . . . [[http://awk.freeshell.org/?action=edit;id=PassingVariablesToTheParentProcess| . . .
1K - last updated 2008-11-19 07:47 UTC by pgas
pattern
In [[awk]], patterns are used to select lines of input for processing. The pattern within each [[rule]] . . . to be matched, in order for the associated [[action]] to take place. The [[action]] only executes . . . in the pattern. In the following example, the [[action]] (to print the line) will occur for each line . . . pattern [[bar]]. === Boolean Patterns === The [[action]]within a [[rule]] will take place, if the [[expression]] . . . [[rule]] does not include a pattern, then the [[action]] within the [[rule]] is performed for every . . .
2K - last updated 2011-05-19 18:18 UTC by markhobley
precedence
The [[awk]] programming language uses rules of *precedence* to determine the order in which [[operator]]s . . . following example, the [[addition]] and [[subtraction]] operators have equal precedence, so the [[operator]]s . . . from left to right. This means that the [[subtraction]] takes place before the [[addition]], because . . . the [[subtraction]] operator occurs on the left side of the [[expression]] . . . because both the [[addition]] and [[subtraction]] operator have equal precedence, the second . . .
7K - last updated 2013-04-11 06:58 UTC by markhobley
PreguntasFrecuentes
<toc> ---- == ¿Cómo muestro un rango de campos? Desde [[RangoDeCampos-español]], [[http://awk.freeshell.org/es?action=edit;id=RangoDeCampos-espa%C3%B1ol| . . . [[http://awk.freeshell.org/es?action=edit;id=UltimoCampo-espa%C3%B1ol|editar]]: <include . . . [[http://awk.freeshell.org/es?action=edit;id=MostrarApostrofos-espa%C3%B1ol|editar]]: . . . [[http://awk.freeshell.org/es?action=edit;id=printf-espa%C3%B1ol|editar]]: <include . . . . . .
2K - last updated 2009-01-03 03:01 UTC by fcr
print
== Usage == === print [ LIST ] === The [[variadic]] **print** function is used to produce simple standardized . . . are equivalent print $0 print }}} == Default action == Note that the default [[action]] within a . . . that match the [[pattern]]. This means that an [[action]] to just print a matching line can be omitted . . .
1K - last updated 2011-05-11 15:10 UTC by markhobley
qse
Not a standalone awk, but an interesting library embedding an awk interpreter, from [[https://groups.google.com/group/comp.lang.awk/browse_thread/thread/b02c0d75e49eab75/54fc2c6316d657bc?lnk=gst&q=c%2B%2B+embed#54fc2c6316d657bc| . . . * open a new runtime context * execute pattern-action blocks or call a function * close the runtime . . . = qse_awk_rtx_loop (rtx); /* exeucte pattern-action blocks */ if (!retv) FAIL (qse_awk_rtx_geterrmsg(rtx)); . . . FAIL (awk); // execute the BEGIN, pattern-action, END blocks. MyAwk::Value r; if (awk.loop (&r) . . .
4K - last updated 2011-10-27 06:25 UTC by pgas
read only variable
=== _User defined variables cannot be marked as readonly_ The [[awk]] extraction and reporting language . . .
1K - last updated 2011-06-01 21:29 UTC by markhobley
reverse
The [[awk]] extraction and reporting language does not provide a [[builtin]] function for reversing strings. . . .
1K - last updated 2011-06-25 05:11 UTC by pgas
rule
Scripts in [[awk]] may contain one or more rules. == Rules consist of patterns and actions == Each rule . . . consists of a [[pattern]] and an associated [[action]]. The [[pattern]] describes a section within . . . to be matched in order for the associated [[action]] to take place. The [[action]] is enclosed . . . to separate it from the pattern: == Patterns or actions can be omitted from a rule == The [[pattern]] . . . or the [[action]] can be omitted from an [[awk]] rule, but it . . .
1K - last updated 2011-05-11 15:07 UTC by markhobley
statement
The [[awk]] extraction and reporting language is not [[imperative]]. However, [[action]]s within the . . .
2K - last updated 2011-05-21 16:43 UTC by markhobley
symbol
| *Symbol* | *Name* | *Purpose* | !! | [[pling]] | logical NOT | " | [[doublequote]] | | # | [[hash]] . . . | !- | [[hyphen]] | negative number prefix, subtraction operator, regular expression range operator . . . compound assignment operator | -= | subtraction compound assignment operator | *= | multiplication . . .
2K - last updated 2013-02-19 14:26 UTC by markhobley
UserPages
User pages are useful to present yourself, add your personal possibly off topic rant start a discussion . . . a simple way is to * [[http://awk.freeshell.org/?action=edit;id=SandBox|edit the sandbox]] * create . . .
1K - last updated 2008-12-31 09:58 UTC by pgas
What is awk
awk is an extraction and reporting language, named after its three original authors: * Alfred V. **A**ho . . .
5K - last updated 2014-11-28 08:24 UTC by pgas
whitespace
== _Line breaks are best placed at whitespace points_ The [[awk]] extraction and reporting language is . . .
1K - last updated 2011-03-20 22:07 UTC by markhobley
55 pages found.