action
== Default action == If a [[rule]] does not include an [[action]], then the default action is used. . . .
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 . . . getline can defeat the simple and usual rule to handle input file transitions: {{{ awk FNR==1 . . .
16K - last updated 2009-02-15 22:14 UTC by waldner
AwkGuide
** Work in Progress ** {{{ import from Mark Hobley's wiki }}} <toc> ---- == Overview * [[Overview]] . . . * [[repeat]] loops * [[return]] * [[RS]] * [[rule]]s * [[search pattern]]s * [[special variable]]s . . .
4K - last updated 2011-08-14 15:57 UTC by markhobley
BEGIN
== Begin Blocks The [[awk]] programming language allows us to use **begin blocks** and **end blocks** . . . awk script. If the script contains only BEGIN rules and no other rules, then the script exits without . . . reading the input, after the BEGIN rules have been run. However, if an END rule exists, . . . the input is read, even if there are no other rules in the program. This behaviour is portable across . . . nawk implementations and exists because the END rule may need to check the FNR and NR variables. Older . . .
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 . . . separate them from the [[pattern]]s within the [[rule]]s: == Grouping of statements == Braces can also . . .
1K - last updated 2010-11-10 22:41 UTC by markhobley
ExitCode
Normally, the `exit' command exits with a value of zero. You can supply an optional numeric value to . . . {{{ awk BEGIN \ { exitcode=0; ... } # normal rules processing... { ... if (fatal) { exitcode=12; . . .
1K - last updated 2008-11-26 12:30 UTC by pgas
FirstFile
you can tell if awk is parsing the first file given on the command line using FILENAME, thusly: {{{ awk . . . BEGIN { rulesfile="" } rulesfile == "" { rulesfile = FILENAME; . . . } FILENAME == rulesfile { build_rule($0); } FILENAME != rulesfile . . . { apply_rule($0); } }}} Example: Suppose you have a text-line . . . some old lines with new lines. {{{ awk BEGIN { rulesfile="" } rulesfile == "" { rulesfile = FILENAME; . . .
1K - last updated 2008-11-18 13:34 UTC by pgas
FirstFileJapanese
you can tell if awk is parsing the first file given on the command line using FILENAME, thusly: {{{ awk . . . BEGIN { rulesfile="" } rulesfile == "" { rulesfile = FILENAME; . . . } FILENAME == rulesfile { build_rule($0); } FILENAME != rulesfile . . . { apply_rule($0); } }}} Example: Suppose you have a text-line . . . some old lines with new lines. {{{ awk BEGIN { rulesfile="" } rulesfile == "" { rulesfile = FILENAME; . . .
1K - last updated 2008-11-24 08:09 UTC by pgas
HomePage
This wiki is maintained by regulars from the **#awk** channel on **[[https://libera.chat/|irc.libera.chat]]** . . . the wiki, just press edit button, the formatting rules are summarized at the bottom of the edit box. . . .
5K - last updated 2023-06-26 04:15 UTC by HappMacDonald
How to edit
<toc> == Editing a page == To edit an existing wiki page, click the “Edit this page” link at the . . . page is just simple text with some formatting rules, for instance *{{{{}}*foo*{{{}}}* will appear . . . font without the * in the html pages. The rules are added at the bottom of the page when you . . . to the [[http://www.wikicreole.org|wiki creole]] rules you can: * put <{{{}}}toc{{{}}}> so that . . .
2K - last updated 2009-03-05 10:18 UTC by pgas
input
The [[awk]] utility can take its input from [[standard input]] or from [[file]]s. If no input files are . . . is sequentially processed according to the [[rule]]s defined within the [[awk]] script. By default, . . .
2K - last updated 2011-05-19 22:40 UTC by markhobley
line orientated
== The awk extraction and reporting language is line orientated == The [[awk]] extraction and reporting . . . is line orientated. The [[action]] for each [[rule]] must begin on the same line as the [[pattern]]. . . . {{{ # A backslash symbol allows this single rule to span multiple lines /foobar/ \ { print $1 } . . . must be appropriately placed within a [[rule]]. . . .
1K - last updated 2011-05-17 23:24 UTC by markhobley
oawk or nawk
you can determine if you have oawk or nawk using the following in a BEGIN rule will do the trick. {{{ . . .
1K - last updated 2008-11-19 13:14 UTC by pgas
oawk or nawkJapanese
you can determine if you have oawk or nawk using the following in a BEGIN rule will do the trick. {{{ . . .
1K - last updated 2008-11-24 08:07 UTC by pgas
Overview
= Overview of awk = == The primarily purpose of awk is to processing textual data to produce formatted . . . the following components: * [[comment]]s * [[rule]]s * [[function]] definitions * [[hashbang]] == . . .
4K - last updated 2011-05-23 23:09 UTC by markhobley
pattern
In [[awk]], patterns are used to select lines of input for processing. The pattern within each [[rule]] . . . matched or the pattern was omitted from the [[rule]]. === Regular Expression Patterns === A pattern . . . Boolean Patterns === The [[action]]within a [[rule]] will take place, if the [[expression]] within . . . true }}} === Omission of the pattern === If a [[rule]] does not include a pattern, then the [[action]] . . . within the [[rule]] is performed for every [[input]] line. . . .
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 . . .
7K - last updated 2013-04-11 06:58 UTC by markhobley
print
== Usage == === print [ LIST ] === The [[variadic]] **print** function is used to produce simple standardized . . . == Note that the default [[action]] within a [[rule]] is to print all [[line]]s that match the [[pattern]]. . . .
1K - last updated 2011-05-11 15:10 UTC by markhobley
regular expression operator
The [[awk]] programming language provides a set of *regular expression operators* that have special meanings . . . regular expression is used as a pattern within a rule_ A binding operator is not required if a regular . . . expression is being used as a pattern within a rule: {{{ # There is no binding operator when a regular . . .
2K - last updated 2013-02-19 14:06 UTC by markhobley
rule
Scripts in [[awk]] may contain one or more rules. == Rules consist of patterns and actions == Each rule . . . == Patterns or actions can be omitted from a rule == The [[pattern]] or the [[action]] can be omitted . . . from an [[awk]] rule, but it is not possible for both the [[pattern]] . . . omitted. === Omission of the pattern === If a [[rule]] does not include a pattern, then the [[action]] . . . within the [[rule]] is performed for every [[input]] line. === Omission . . .
1K - last updated 2011-05-11 15:07 UTC by markhobley
SedFAQ
<toc> ---- == I have a line like "abdcgfjeuPATTERNfjfhghj", I want to get the PATTERN part, why . . . how to delimit the line according to the rule above, and whether the odd-numbered or even-numbered . . .
34K - last updated 2010-02-14 17:56 UTC by waldner
semicolon
== Separation of statements == The [[semicolon]] symbol can be used to separate multiple [[statement]]s . . . is optional and can be omitted. == Separation of rules == Rules can also be placed together on a single . . .
1K - last updated 2010-11-28 19:46 UTC by markhobley
SpecialFile
You can use `-v rulesfile=filename' to process a file differently, like you would any other variable, . . . in your BEGIN statement. {{{ awk BEGIN \ { if (rulesfile=="") { print "must use -v rulesfile=filename"; . . . exit(1); } while ( (getline < rulesfile) >0 ) replace[$1]=$0; close(rulesfile); . . .
1K - last updated 2008-11-18 13:37 UTC by pgas
SpecialFileJapanese
You can use `-v rulesfile=filename' to process a file differently, like you would any other variable, . . . in your BEGIN statement. {{{ awk BEGIN \ { if (rulesfile=="") { print "must use -v rulesfile=filename"; . . . exit(1); } while ( (getline < rulesfile) >0 ) replace[$1]=$0; close(rulesfile); . . .
1K - last updated 2008-11-24 08:09 UTC by pgas
statement
The [[awk]] extraction and reporting language is not [[imperative]]. However, [[action]]s within the . . . awk [[rule]]s may contain *statements* which can be executed . . . awk program is a separate statement or separate rule, and the end of the line is treated as the end . . . of the statement or rule: == The semicolon symbol can be used to separate . . . [[semicolon]] after the last statement within a rule is optional and can be omitted: == Statements . . .
2K - last updated 2011-05-21 16:43 UTC by markhobley
symbol
| *Symbol* | *Name* | *Purpose* | !! | [[pling]] | logical NOT | " | [[doublequote]] | | # | [[hash]] . . . | | ; | [[semicolon]] | statement separator, rule separator | < | [[lessthan]] | | = | [[equals]] . . .
2K - last updated 2013-02-19 14:26 UTC by markhobley
26 pages found.