加入收藏 | 设为首页 | 会员中心 | 我要投稿 温州站长网 (https://www.0577zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

awk - Unix, Linux Command---reference

发布时间:2021-01-30 02:45:05 所属栏目:Linux 来源:网络整理
导读:副标题#e# http://www.tutorialspoint.com/unix_commands/awk.htm gawk - pattern scanning and processing language gawk?[?POSIX?or?GNU?style options ]?-f? program-file ?[?--?] file ...?gawk?[?POSIX?or?GNU?style options ] [?--?]? program-text ?
</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>

Arrays

Arrays 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?"A34B34C". 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.

(编辑:温州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

</tr>
<tr valign="top">
<td>PROCINFO["FS"]</td>
<td valign="bottom">
"FS"?if field splitting with?FS?is in effect,or?"FIELDWIDTHS"?if field splitting with?FIELDWIDTHS?is in effect.</td>

</tr>
<tr valign="top">
<td>PROCINFO["gid"]</td>
<td valign="bottom">the value of the?getgid(2) system call.</td>

</tr>
<tr valign="top">
<td>PROCINFO["pgrpid"]</td>
<td valign="bottom">the process group ID of the current process.</td>

</tr>
<tr valign="top">
<td>PROCINFO["pid"]</td>
<td valign="bottom">the process ID of the current process.</td>

</tr>
<tr valign="top">
<td>PROCINFO["ppid"]</td>
<td valign="bottom">the parent process ID of the current process.</td>

</tr>
<tr valign="top">
<td>PROCINFO["uid"]</td>
<td valign="bottom">the value of the?getuid(2) system call.</td>

</tr>
<tr valign="top">
<td colspan="2">PROCINFO["version"]</td>

</tr>
<tr valign="top">
<td width="17%">?</td>
<td>The version of?gawk. This is available from version 3.1.4 and later.</td>

</tr>

热点阅读