awk - Unix, Linux Command---reference
</tr> </tr> </tr> </tr> </tr> </tr> </tr> </tr> </tr> |
<tr valign="top">
<td>RS</td>
<td valign="bottom">The input record separator,by default a newline.</td>
</tr>
<tr valign="top">
<td>RT</td>
<td valign="bottom">The record terminator.?Gawk?sets?RT?to the input text that matched the character or regular expression specified by?RS.</td>
</tr>
<tr valign="top">
<td>RSTART</td>
<td valign="bottom">The index of the first character matched by?match(); 0 if no match. (This implies that character indices start at one.)</td>
</tr>
<tr valign="top">
<td>RLENGTH</td>
<td valign="bottom">The length of the string matched by?match(); -1 if no match.</td>
</tr>
<tr valign="top">
<td>SUBSEP</td>
<td valign="bottom">The character used to separate multiple subscripts in array elements,by default?" 34".</td>
</tr>
<tr valign="top">
<td>TEXTDOMAIN</td>
<td valign="bottom">The text domain of the?AWK?program; used to find the localized translations for the program’s strings.</td>
</tr>
ArraysArrays are subscripted with an expression between square brackets ([?and?]). If the expression is an expression list (expr,?expr?...) then the array subscript is a string consisting of the concatenation of the (string) value of each expression,separated by the value of the?SUBSEP?variable. This facility is used to simulate multiply dimensioned arrays. For example:
i = "A"; j = "B"; k = "C"?x[i,j,k] = "hello,worldn"
assigns the string?"hello,worldn"?to the element of the array?x?which is indexed by the string?"A 34B 34C". All arrays in?AWK?are associative,i.e. indexed by string values.
The special operator?in?may be used in an?if?or?while?statement to see if an array has an index consisting of a particular value.
<table class="src" cellspacing="5" cellpadding="5">
<tr><td>
if (val in array) ????????print array[val]If the array has multiple subscripts,use?(i,j) in array.
The?in?construct may also be used in a?for?loop to iterate over all the elements of an array.
An element may be deleted from an array using the?delete?statement. The?deletestatement may also be used to delete the entire contents of an array,just by specifying the array name without a subscript.
Variable Typing And Conversion
Variables and fields may be (floating point) numbers,or strings,or both. How the value of a variable is interpreted depends upon its context. If used in a numeric expression,it will be treated as a number,if used as a string it will be treated as a string.
To force a variable to be treated as a number,add 0 to it; to force it to be treated as a string,concatenate it with the null string.
(编辑:ASP站长)
【免责声明】本站内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。
-
无相关信息