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 . . . while ( (getline < file) > 0) { if ($1 == "include") { read($2) } else { print > ARGV[2] } . . . above not only expands all the lines that say "include subfile", but by writing the result to a tmp . . .
16K - last updated 2009-02-15 22:14 UTC by waldner
awk.exe
[[awk.exe]] Last edited 2013-05-27 23:57:16 PDT\\ The first is from Dr. Kernighan - the k of awk.\\ gawk . . . (requires the four .dll files included in the .zip download)\\ from: http://www.klabaster.com/freeware.htm\\ . . .
2K - last updated 2013-05-28 07:57 UTC by g0ph3r
AwkDc
This is an awk implementation of the [http://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html|dc] . . . Notably, this version of dc is intended to include tail-call elimination for macro calls. Tail . . .
12K - last updated 2008-07-17 14:47 UTC by gnomon
AwkGuide
** Work in Progress ** {{{ import from Mark Hobley's wiki }}} <toc> ---- == Overview * [[Overview]] . . . * [[if]] conditional constructs * [[include]] files * [[infinite loop]]s * [[input]] * . . .
4K - last updated 2011-08-14 15:57 UTC by markhobley
AwkOnWindows
[[AwkOnWindows|This page]] lists available versions of awk for ms windows.\\ Example: //awk /foo/{print(NR,$0)} . . . is ok for XP and Vista. Other versions of awk include [[http://www.gnu.org/software/gawk/manual/| . . .
2K - last updated 2010-10-24 09:39 UTC by g0pher
BeforeAfterMatch
Problem: print the Nth record before or after a certain regular expression matches or, alternativley, . . . }}} Use i=0 in the for definition if you want to include the matching record itself. iiii) Print every . . .
3K - last updated 2009-02-28 20:38 UTC by waldner
CAAN-or-caan
**caan: the comprehensive awk archive network**\\ -or-\\ . . . has MPFR; requires the four .dll files included there\\ exe: http://www.klabaster.com/freeware.htm\\ . . .
4K - last updated 2014-05-29 02:01 UTC by g0ph3r
command line parameter
The [[awk]] extraction and reporting language uses traditional conventions for accessing command line . . . the [[script]] or [[pathname]] components may be included. . . .
1K - last updated 2011-06-25 05:49 UTC by pgas
comment
Comments are pieces of text or [[whitespace]] that can be included in a program to make the code more . . .
1K - last updated 2009-07-15 17:07 UTC by MarkHobley
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/ . . . <toc> ---- == What is Awk? <include "What is awk"> [[http://awk.freeshell.org/?action=edit;id=What_is_awk| . . . variables in an awk script? === Shells <include "Shells"> [[http://awk.freeshell.org/?action=edit;id=Shells| . . . === Environment variables in general <include "EnvVarGeneral"> [[http://awk.freeshell.org/?action=edit;id=EnvVarGeneral| . . . Edit this answer]] === Unix Shell Quoting <include "ShellQuoting"> [[http://awk.freeshell.org/?action=edit;id=ShellQuoting| . . .
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/ . . . <toc> ---- == What is Awk? <include "What is awkJapanese"> [[http://awk.freeshell.org/?action=edit;id=What_is_awkJapanese| . . . variables in an awk script? === Shells <include "ShellsJapanese"> [[http://awk.freeshell.org/?action=edit;id=ShellsJapanese| . . . === Environment variables in general <include "EnvVarGeneralJapanese"> [[http://awk.freeshell.org/?action=edit;id=EnvVarGeneralJapanese| . . . Edit this answer]] === Unix Shell Quoting <include "ShellQuotingJapanese"> [[http://awk.freeshell.org/?action=edit;id=ShellQuotingJapanese| . . .
4K - last updated 2008-11-24 09:01 UTC by pgas
compound assignment operator
The *compound assignment operators* (also called *combination assignment operators*) provide a more concise . . . to be performed without the [[variable]] being included in the right hand [[operand]]. {{{ $value . . .
2K - last updated 2011-03-27 09:46 UTC by markhobley
ConvertHexToFloatingPoint
This code uses [[gawkism|gawk specific features]], such as the [[http://www.gnu.org/manual/gawk/html_node/Strtonum-Function.html][strtonum]] . . . } END { } }}} = C++ code for test program {{{ #include <stdio.h> #include <stdlib.h> #include . . .
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 . . . all the fields(columns) of a Record(lines) <include "LoopOnFields"> [[http://awk.freeshell.org/?action=edit;id=LoopOnFields| . . . ---- == How to test if an array is empty <include "EmptyArray"> [[http://awk.freeshell.org/?action=edit;id=EmptyArray| . . . this answer]] ---- == How to "join" an array <include "JoinArray"> [[http://awk.freeshell.org/?action=edit;id=JoinArray| . . . on a line for a given regular expression <include "LastMatchOnLine"> [[http://awk.freeshell.org/?action=edit;id=LastMatchOnLine| . . .
1K - last updated 2009-04-14 09:03 UTC by 216.162.199.202
escape sequence
Some characters cannot be included in [[literal string]]s, because they are [[nonprintable]] or [[control . . . symbol is another character that cannot be included in an [[interpolated]] string. This is because . . .
3K - last updated 2008-12-30 13:07 UTC by Mark Hobley
faster awk
1) optimize your code ie array references are slow 2) use a faster awk mawk 3) use gawk ability to include . . .
1K - last updated 2012-04-20 07:21 UTC by g0pher
FileName
the file name is stored in the built-in variable FILENAME: {{{ awk '/^#include/ {print FILENAME,$2}' . . .
1K - last updated 2008-11-18 13:31 UTC by pgas
FileNameJapanese
the file name is stored in the built-in variable FILENAME: {{{ awk '/^#include/ {print FILENAME,$2}' . . .
1K - last updated 2008-11-24 08:08 UTC by pgas
FIXES
[[FIXES]] revised: . . . advance to next input file.\\ printf("%c", 0) to include a null byte in output.\\ added a "-safe" argument . . .
6K - last updated 2014-01-15 23:17 UTC by g0ph3r
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]]) . . . a RangeOfFields, eg from field 2 to the end? <include "RangeOfFields"> [[http://awk.freeshell.org/?action=edit;id=RangeOfFields| . . . the LastField or the n'th field in a record? <include "LastField"> [[http://awk.freeshell.org/?action=edit;id=LastField| . . . why do I get 1e+06 instead of 1000001.10? <include "PrintingNumbers"> [[http://awk.freeshell.org/?action=edit;id=PrintingNumbers| . . . == How do I edit a file in place with awk? <include "EditInPlace"> [[http://awk.freeshell.org/?action=edit;id=EditInPlace| . . .
3K - last updated 2015-09-08 08:46 UTC by pgas
hashbang
== A script can be treated as an executable file by using a hashbang == It is possible for an awk script . . . command line is structured, it is necessary to include a -f command line switch on the hashbang line. . . .
1K - last updated 2010-11-28 19:04 UTC by markhobley
HomePage
This wiki is maintained by regulars from the **#awk** channel on **[[https://libera.chat/|irc.libera.chat]]** . . . it is all very abstract) * [[Recursively Include C headers]] * Eric S Raymond's https://gitlab.com/esr/tapview . . .
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 . . . (not the rendering of the toc in the * use <include pagename> to include the content from another . . .
2K - last updated 2009-03-05 10:18 UTC by pgas
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
Inicio
Este wiki es mantenido por los usuarios del cenal **#awk** en **[[http://www.freenode.net|irc.freenode.net]]**. . . . Reference", The Single UNIX Specification (includes a nifty section defining the precise grammar . . . it is all very abstract) ** [[Recursively Include C headers]] ---- == Enlaces * the traditional . . .
7K - last updated 2009-02-12 23:31 UTC by fcr
Invoking an awk program
=== Throwaway one-liners It is often useful to type a simple program at the command line for use within . . . of the [[awk]] command line, it is necessary to include a the -f switch in the [[hashbang]] line as . . .
1K - last updated 2008-12-31 11:34 UTC by pgas
iterative loop
An '''iterative loop''' repeatedly executes a set of instructions as the [iterator] steps through a series . . . of values. Types of iterative loops include [for] loops and [foreach] loops. == For loops . . .
2K - last updated 2011-08-13 21:00 UTC by markhobley
LevenshteinEditDistance
The [http://en.wikipedia.org/wiki/Levenshtein_distance|Levenshtein edit distance] calculation is useful . . . hi_saito's code is linked to rather than included outright because no licensing terms appear . . .
6K - last updated 2010-04-16 10:19 UTC by pgas
libmawk
libmawk is a fork of [[mawk]], designed for embedding in C programs. Compare and contrast with [[awka]]. . . . returns the value of a variable by name) ** include "source.awk" allows an awk source to include . . .
2K - last updated 2012-01-16 09:07 UTC by lewellyn
LinksPage
<toc> ---- == websites dedicated to awk == * [[http://awk.info/|awk.info]] news and articles about . . . Reference", The Single UNIX Specification (includes a nifty section defining the precise grammar . . .
4K - last updated 2015-02-24 14:45 UTC by pgas
literal characters
== Special characters cannot be directly included in a literal string == Special characters, such as . . . character]]s or [[metacharacter]]s cannot be included directly in a [[string]] value. This is because . . .
2K - last updated 2010-11-28 19:14 UTC by markhobley
MultipleFiles
<toc> === Version warning Some of these techniques will require non-ancient versions of awk. === . . . can awk test for the existence of a file? <include "FileExistence"> [[http://awk.freeshell.org/?action=edit;id=FileExistence| . . . How can I get awk to read multiple files? <include "ReadMultipleFiles"> [[http://awk.freeshell.org/?action=edit;id=ReadMultipleFiles| . . . I tell from which file my input is coming? <include "FileName"> [[http://awk.freeshell.org/?action=edit;id=FileName| . . . open multiple files (selected at runtime)? <include "OpeningFiles"> [[http://awk.freeshell.org/?action=edit;id=OpeningFiles| . . .
2K - last updated 2008-11-18 13:38 UTC by pgas
PassingVariables
<toc> === Shells <include "Shells"> [[http://awk.freeshell.org/?action=edit;id=Shells| Edit . . . === Environment variables in general <include "EnvVarGeneral"> [[http://awk.freeshell.org/?action=edit;id=EnvVarGeneral| . . . Edit this answer]] === Unix Shell Quoting <include "ShellQuoting"> [[http://awk.freeshell.org/?action=edit;id=ShellQuoting| . . . answer]] === ENVIRON[] and "env"|getline <include "ENVIRON"> [[http://awk.freeshell.org/?action=edit;id=ENVIRON| . . . variables back to the parent process <include "PassingVariablesToTheParentProcess"> [[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]] . . . of the pattern === If a [[rule]] does not include a pattern, then the [[action]] within the [[rule]] . . .
2K - last updated 2011-05-19 18:18 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| . . . editar]]: <include "RangoDeCampos-español"> ---- == ¿Cómo muestro . . . <include "UltimoCampo-español"> ---- == ¿Cómo muestro . . . <include "MostrarApostrofos-español"> ---- == ¿Cómo . . . <include "printf-español"> ---- == ¿Cómo encontrar . . .
2K - last updated 2009-01-03 03:01 UTC by fcr
PrintASingleQuote
This question gets asked often enough that it deserves its own answer. This common question doesn't actually . . . quote characters. ==== Being Creative Other ways include: escaping the single quote in the shell ('\'') . . .
5K - last updated 2015-07-05 09:45 UTC by pitman
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| . . . BEGIN { print "hello, world" } }}} {{{ cc #include <qse/awk/std.h> #include <qse/cmn/stdio.h> . . . runtime context for each interpreter. {{{ cpp #include <qse/awk/StdAwk.hpp> #include <iostream> . . .
4K - last updated 2011-10-27 06:25 UTC by pgas
RangeOfFields
Printing a range of fields - all fields but the first, for examples, or fields 3 through 8 - is a surprisingly . . . --posix to get full POSIX compatibility, which includes repetition operators). If FS is not the default, . . . the last field (meaning that any whitespace is included). It then uses printf to space-pad the field . . .
10K - last updated 2015-09-08 09:52 UTC by pgas
ReadMultipleFiles
awk automatically reads multiple files (under Unix at least) -- use something like: {{{ awk '/^#include/ . . .
1K - last updated 2008-11-18 13:30 UTC by pgas
ReadMultipleFilesJapanese
awk automatically reads multiple files (under Unix at least) -- use something like: {{{ awk '/^#include/ . . .
1K - last updated 2008-11-24 08:08 UTC by pgas
Recursively Include C headers
=== Problem Specification i want to generate one big .hpp file out of multiple .hpp files and want to . . . include the text of all #include "foo.hpp" file recursively . . . {{{ awk #!/usr/bin/awk -f # by goedel BEGIN { include_path = "." iplen = split(include_path, ip, . . . f, file) { if (match(line, /^[ \t]*#include[ \ ]*"[^"]+"/)) { f = substr(line, RSTART, . . . RLENGTH) sub(/^[ \t]*#include[ \t]*"/, "", f) sub(/"/, "", f) file = complete_path(f) . . .
1K - last updated 2011-12-11 05:33 UTC by pgas
rule
Scripts in [[awk]] may contain one or more rules. == Rules consist of patterns and actions == Each rule . . . of the pattern === If a [[rule]] does not include a pattern, then the [[action]] within the [[rule]] . . . of the action === If a [[rule]] does not include an [[action]], then the [[default action]] . . .
1K - last updated 2011-05-11 15:07 UTC by markhobley
SolarisNawk
I want to use the tolower() function with {{{SunOS}}} nawk, but all I get is {{{ nawk: calling undefined . . . {{{Patrick TJ McPhee}}} writes: {{{ > SunOS includes three versions of awk. /usr/bin/awk is the . . .
1K - last updated 2008-11-24 08:24 UTC by pgas
SolarisNawkJapanese
I want to use the tolower() function with {{{SunOS}}} nawk, but all I get is {{{ nawk: calling undefined . . . {{{Patrick TJ McPhee}}} writes: {{{ > SunOS includes three versions of awk. /usr/bin/awk is the . . .
1K - last updated 2008-11-24 08:36 UTC by pgas
string
== _Literal strings are delimited using doublequotes_ In [[awk]], literal strings are delimited using . . . string]]. == Backslash notation can be used to include special characters_ It is possible to include . . .
1K - last updated 2010-10-19 21:58 UTC by markhobley
46 pages found.