awk:awk_variables
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
awk:awk_variables [2020/05/06 18:53] – peter | awk:awk_variables [2021/01/06 15:55] (current) – [FNR] peter | ||
---|---|---|---|
Line 28: | Line 28: | ||
|PROCINFO|Information about the process.| | |PROCINFO|Information about the process.| | ||
|RLENGTH|The length of the string matched by the match function.| | |RLENGTH|The length of the string matched by the match function.| | ||
+ | |RSTART|The first position in the string matched by match function.| | ||
|RS|The input record separator, by default a newline.| | |RS|The input record separator, by default a newline.| | ||
|RT|The record terminator.| | |RT|The record terminator.| | ||
|SUBSEP|The character used to separate multiple subscripts in array elements, by default " | |SUBSEP|The character used to separate multiple subscripts in array elements, by default " | ||
+ | |TEXTDOMAIN|The text domain of the AWK program. | ||
+ | |||
---- | ---- | ||
Line 59: | Line 62: | ||
It represents the index in ARGV of the current file being processed. | It represents the index in ARGV of the current file being processed. | ||
- | < | + | < |
awk ' | awk ' | ||
print " | print " | ||
Line 120: | Line 123: | ||
Its default value is %.6g. | Its default value is %.6g. | ||
- | < | + | < |
awk 'BEGIN { print " | awk 'BEGIN { print " | ||
</ | </ | ||
Line 156: | Line 159: | ||
A string indicates an error when a redirection fails for getline or if a close call fails. | A string indicates an error when a redirection fails for getline or if a close call fails. | ||
- | < | + | < |
awk 'BEGIN { ret = getline < " | awk 'BEGIN { ret = getline < " | ||
</ | </ | ||
Line 201: | Line 204: | ||
It represents the number of the current record in the current file. | It represents the number of the current record in the current file. | ||
+ | |||
+ | <code bash> | ||
+ | echo -e "One Two\nOne Two Three\nOne Two Three Four" | awk 'FNR < 3' | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | < | ||
+ | One Two | ||
+ | One Two Three | ||
+ | </ | ||
<WRAP info> | <WRAP info> | ||
Line 230: | Line 244: | ||
When this variable is set, GAWK becomes case-insensitive. | When this variable is set, GAWK becomes case-insensitive. | ||
- | < | + | < |
awk ' | awk ' | ||
</ | </ | ||
Line 239: | Line 253: | ||
10 | 10 | ||
</ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | <code bash> | ||
+ | awk ' | ||
+ | </ | ||
+ | |||
+ | </ | ||
---- | ---- | ||
Line 250: | Line 273: | ||
When assigned the string value fatal, lint warnings become fatal errors, exactly like **--lint=fatal**. | When assigned the string value fatal, lint warnings become fatal errors, exactly like **--lint=fatal**. | ||
- | < | + | < |
awk 'BEGIN {LINT = 1; a}' | awk 'BEGIN {LINT = 1; a}' | ||
</ | </ | ||
Line 261: | Line 284: | ||
</ | </ | ||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
---- | ---- | ||
Line 306: | Line 332: | ||
It represents the output format number and its default value is %.6g. | It represents the output format number and its default value is %.6g. | ||
- | < | + | < |
awk 'BEGIN {print "OFMT = " OFMT}' | awk 'BEGIN {print "OFMT = " OFMT}' | ||
</ | </ | ||
Line 322: | Line 348: | ||
It represents the output field separator and its default value is space. | It represents the output field separator and its default value is space. | ||
- | < | + | < |
awk 'BEGIN {print "OFS = " OFS}' | cat -vte | awk 'BEGIN {print "OFS = " OFS}' | cat -vte | ||
</ | </ | ||
Line 338: | Line 364: | ||
It represents the output record separator and its default value is newline. | It represents the output record separator and its default value is newline. | ||
- | < | + | < |
awk 'BEGIN {print "ORS = " ORS}' | cat -vte | awk 'BEGIN {print "ORS = " ORS}' | cat -vte | ||
</ | </ | ||
Line 355: | Line 381: | ||
This is an associative array containing information about the process, such as real and effective UID numbers, process ID number, and so on. | This is an associative array containing information about the process, such as real and effective UID numbers, process ID number, and so on. | ||
- | < | + | < |
awk 'BEGIN { print PROCINFO[" | awk 'BEGIN { print PROCINFO[" | ||
</ | </ | ||
Line 373: | Line 399: | ||
AWK's match function searches for a given string in the input-string. | AWK's match function searches for a given string in the input-string. | ||
- | < | + | < |
awk 'BEGIN { if (match(" | awk 'BEGIN { if (match(" | ||
</ | </ | ||
Line 390: | Line 416: | ||
It represents (input) record separator and its default value is newline. | It represents (input) record separator and its default value is newline. | ||
- | < | + | < |
awk 'BEGIN {print "RS = " RS}' | cat -vte | awk 'BEGIN {print "RS = " RS}' | cat -vte | ||
</ | </ | ||
Line 407: | Line 433: | ||
It represents the first position in the string matched by match function. | It represents the first position in the string matched by match function. | ||
- | < | + | < |
awk 'BEGIN { if (match(" | awk 'BEGIN { if (match(" | ||
</ | </ | ||
Line 423: | Line 449: | ||
It represents the separator character for array subscripts and its default value is \034. | It represents the separator character for array subscripts and its default value is \034. | ||
- | < | + | < |
awk 'BEGIN { print " | awk 'BEGIN { print " | ||
</ | </ | ||
Line 439: | Line 465: | ||
It represents the entire input record. | It represents the entire input record. | ||
- | < | + | < |
awk ' | awk ' | ||
</ | </ | ||
Line 462: | Line 488: | ||
It is used to find the localized translations for the program' | It is used to find the localized translations for the program' | ||
- | < | + | < |
awk 'BEGIN { print TEXTDOMAIN }' | awk 'BEGIN { print TEXTDOMAIN }' | ||
</ | </ | ||
Line 483: | Line 509: | ||
It represents the nth field in the current record where the fields are separated by FS. | It represents the nth field in the current record where the fields are separated by FS. | ||
- | < | + | < |
awk ' | awk ' | ||
</ | </ |
awk/awk_variables.1588791192.txt.gz · Last modified: 2020/07/15 09:30 (external edit)