# length
length([s])
Length of string s (or $0), or element count of an array.
awkrs v0.4.17 · 86 topics · 8 chapters · generated from awkrs/src/lsp.rs
Every builtin, special variable, and keyword awkrs documents, rendered from the exact markdown that the awkrs LSP shows on hover. Jump via the chapter index, or Ctrl+F for a specific name.
lengthlength([s])
Length of string s (or $0), or element count of an array.
substrsubstr(s, m [, n])
n-char substring of s starting at position m (1-based).
indexindex(s, t)
1-based position of t in s, or 0 if not found.
splitsplit(s, arr [, fs [, seps]])
Split s into arr on fs; returns the field count.
subsub(re, repl [, target])
Replace first match of re in target ($0); returns 1/0.
gsubgsub(re, repl [, target])
Replace all matches of re in target ($0); returns count.
matchmatch(s, re [, arr])
Set RSTART/RLENGTH to the match of re in s; returns position or 0.
sprintfsprintf(fmt, ...)
Format the arguments per fmt and return the string.
tolowertolower(s)
Copy of s with uppercase letters lowercased.
touppertoupper(s)
Copy of s with lowercase letters uppercased.
gensubgensub(re, repl, how [, target])
Non-destructive global/Nth substitution returning the new string.
sinsin(x)
Sine of x (radians).
coscos(x)
Cosine of x (radians).
atan2atan2(y, x)
Arctangent of y/x in radians.
expexp(x)
e raised to the power x.
loglog(x)
Natural logarithm of x.
sqrtsqrt(x)
Square root of x.
intint(x)
Integer part of x, truncated toward zero.
randrand()
Pseudo-random number in [0, 1).
srandsrand([x])
Seed the RNG with x (or time); returns the previous seed.
printprint — keyword
Write its arguments to output, separated by OFS and terminated by ORS.
printfprintf(fmt, ...)
Format and print the arguments per fmt.
getlinegetline — keyword
Read the next record into $0 or a variable from input, a file, or a command.
closeclose(file [, how])
Close an open file/pipe; returns its status.
systemsystem(cmd)
Run cmd via the shell; returns its exit status.
fflushfflush([file])
Flush buffers for file, or all outputs if omitted.
systimesystime()
Current time as seconds since the epoch (gawk).
strftimestrftime([fmt [, ts [, utc]]])
Format timestamp ts per fmt (gawk).
mktimemktime(spec [, utc])
Convert a "YYYY MM DD HH MM SS [DST]" spec to a timestamp (gawk).
andand(v1, v2, ...)
Bitwise AND of the arguments (gawk).
oror(v1, v2, ...)
Bitwise OR of the arguments (gawk).
xorxor(v1, v2, ...)
Bitwise XOR of the arguments (gawk).
complcompl(v)
Bitwise complement of v (gawk).
lshiftlshift(v, n)
v left-shifted by n bits (gawk).
rshiftrshift(v, n)
v right-shifted by n bits (gawk).
typeoftypeof(x)
Type of x: "scalar", "array", "untyped", … (gawk).
isarrayisarray(x)
1 if x is an array, else 0 (gawk).
patsplitpatsplit(s, arr [, fpat [, seps]])
Split s into arr by the pattern fpat (gawk).
asortasort(src [, dst [, how]])
Sort array values; returns the element count (gawk).
asortiasorti(src [, dst [, how]])
Sort array indices; returns the element count (gawk).
NRNR — special variable
Total number of input records read so far.
NFNF — special variable
Number of fields in the current record.
FSFS — special variable
Input field separator (default " ").
OFSOFS — special variable
Output field separator (default " ").
ORSORS — special variable
Output record separator (default "\n").
RSRS — special variable
Input record separator (default "\n").
FILENAMEFILENAME — special variable
Name of the current input file.
FNRFNR — special variable
Record number within the current input file.
RSTARTRSTART — special variable
Start position of the last match() (1-based), or 0.
RLENGTHRLENGTH — special variable
Length of the last match(), or -1.
SUBSEPSUBSEP — special variable
Subscript separator for multi-dimensional array keys.
ARGCARGC — special variable
Count of command-line arguments in ARGV.
ARGVARGV — special variable
Array of command-line arguments.
ENVIRONENVIRON — special variable
Array of the process environment variables.
CONVFMTCONVFMT — special variable
Conversion format for numbers used as strings (default "%.6g").
OFMTOFMT — special variable
Output format for numbers in print (default "%.6g").
IGNORECASEIGNORECASE — special variable
When non-zero, regex and string comparisons ignore case (gawk).
FIELDWIDTHSFIELDWIDTHS — special variable
Space-separated fixed field widths for parsing (gawk).
FPATFPAT — special variable
Regexp describing field contents, as an alternative to FS (gawk).
PROCINFOPROCINFO — special variable
Array of process/runtime information (gawk).
RTRT — special variable
Text matched by RS for the current record (gawk).
ERRNOERRNO — special variable
Description of the last getline/close/system error (gawk).
TEXTDOMAINTEXTDOMAIN — special variable
Text domain for string translation (gawk).
BINMODEBINMODE — special variable
Binary I/O mode control (gawk).
LINTLINT — special variable
Dynamic control of lint warnings (gawk).
BEGINBEGIN — keyword
Special pattern whose action runs once before any input is read.
ENDEND — keyword
Special pattern whose action runs once after all input is consumed.
BEGINFILEBEGINFILE — keyword
Pattern whose action runs before each input file is read (gawk).
ENDFILEENDFILE — keyword
Pattern whose action runs after each input file is processed (gawk).
functionfunction — keyword
Define a user function: function name(params) { body }.
ifif — keyword
Conditional statement: if (cond) stmt with an optional else branch.
elseelse — keyword
The alternative branch taken when an if condition is false.
whilewhile — keyword
Loop that repeats stmt while cond is true: while (cond) stmt.
forfor — keyword
Loop: for (init; cond; incr) stmt, or for (key in array) stmt.
dodo — keyword
Do-while loop: do stmt while (cond); the body runs at least once.
breakbreak — keyword
Exit the innermost for, while, or do loop immediately.
continuecontinue — keyword
Skip to the next iteration of the innermost loop.
nextnext — keyword
Stop processing the current record and read the next one.
nextfilenextfile — keyword
Stop processing the current input file and advance to the next.
exitexit — keyword
Stop reading input and run END; exit [expr] sets the exit status.
returnreturn — keyword
Return from a user function, optionally with a value: return [expr].
deletedelete — keyword
Remove an array element (delete arr[k]) or clear it (delete arr).
switchswitch — keyword
Multi-way branch on a value: switch (expr) { case ...: ... } (gawk).
casecase — keyword
A labeled branch inside a switch statement (gawk).
defaultdefault — keyword
The fallback branch taken when no case matches in a switch (gawk).
inin — keyword
Array membership test (key in arr) or iteration (for (key in arr)).