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

awk - Unix, Linux Command---reference

发布时间:2021-01-24 20:35:25 所属栏目:Linux 来源:网络整理
导读: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-

For example,before the?POSIX?standard,to match alphanumeric characters,you would have had to write?/[A-Za-z0-9]/. If your character set had other alphabetic characters in it,this would not match them,and if your character set collated differently from?ASCII,this might not even match the?ASCII?alphanumeric characters. With the?POSIX?character classes,you can write?/[[:alnum:]]/,and this matches the alphabetic and numeric characters in your character set.

Two additional special sequences can appear in character lists. These apply to non-ASCII?character sets,which can have single symbols (called?collating elements) that are represented with more than one character,as well as several characters that are equivalent for?collating,or sorting,purposes. (E.g.,in French,a plain ‘‘e’’ and a grave-accented e` are equivalent.)

</tr>
<tr valign="top">
<td width="6%">?</td>
<td>A collating symbol is a multi-character collating element enclosed in?[.?and?.]. For example,if?ch?is a collating element,then[[.ch.]]?is a regular expression that matches this collating element,while?[ch]?is a regular expression that matches eitherc?or?h.</td>

</tr>
<tr valign="top">
<td colspan="2">Equivalence Classes</td>

</tr>
<tr valign="top">
<td width="6%">?</td>
<td>An equivalence class is a locale-specific name for a list of characters that are equivalent. The name is enclosed in?[=?and=]. For example,the name?e?might be used to represent all of ‘‘e,’’ ‘‘e',’’ and ‘‘e.’’ In this case,?<strong>[[=e=]]</strong>?is a regular expression that matches any of?<strong>e</strong>,?<strong>e'</strong>,or?<strong>e.</td>

</tr>
<tr>
<td colspan="2">These features are very valuable in non-English speaking locales. The library functions that?gawk?uses for regular expression matching currently only recognize?POSIXcharacter classes; they do not recognize collating symbols or equivalence classes.</td>

</tr>
<tr>
<td colspan="2">The?y,?B,?&;,?>,?w,?W,?‘,and?’?operators are specific to?gawk; they are extensions based on facilities in the?GNU?regular expression libraries.</td>

</tr>
<tr>
<td colspan="2">The various command line options control how?gawk?interprets characters in regular expressions.</td>

</tr>
<tr valign="top">
<td colspan="2">No options</td>

</tr>
<tr valign="top">
<td width="6%">?</td>
<td>In the default case,?gawk?provide all the facilities of?POSIXregular expressions and the?GNU?regular expression operators described above. However,interval expressions are not supported.</td>

</tr>
<tr valign="top">
<td>--posix</td>
<td valign="bottom">Only?POSIX?regular expressions are supported,the?GNUoperators are not special. (E.g.,?w?matches a literal?w). Interval expressions are allowed.</td>

</tr>
<tr valign="top">
<td colspan="2">--traditional</td>

</tr>
<tr valign="top">
<td width="6%">?</td>
<td>Traditional Unix?awk?regular expressions are matched. The?GNUoperators are not special,interval expressions are not available,and neither are the?POSIX?character classes ([[:alnum:]]?and so on). Characters described by octal and hexadecimal escape sequences are treated literally,even if they represent regular expression metacharacters.</td>

</tr>
<tr valign="top">
<td colspan="2">--re-interval</td>

</tr>
<tr valign="top">
<td width="6%">?</td>
<td>Allow interval expressions in regular expressions,even if?--traditional?has been provided.</td>

</tr>

Actions

Action statements are enclosed in braces,?{?and?}. Action statements consist of the usual assignment,conditional,and looping statements found in most languages. The operators,control statements,and input/output statements available are patterned after those in C.

Operators

The operators in?AWK,in order of decreasing precedence,are

<table class="src" border="1" cellspacing="0" cellpadding="5">


<tr>
<th width="25%">Tag

</tr>
<tr valign="top">
<td>$</td>
<td valign="bottom">Field reference.</td>

</tr>
<tr valign="top">
<td>++ --</td>
<td valign="bottom">Increment and decrement,both prefix and postfix.</td>

</tr>
<tr valign="top">
<td>^</td>
<td valign="bottom">Exponentiation (?may also be used,and?=?for the assignment operator).</td>

</tr>
<tr valign="top">
<td>+ - !</td>
<td valign="bottom">Unary plus,unary minus,and logical negation.</td>

</tr>
<tr valign="top">
<td>* / %</td>
<td valign="bottom">Multiplication,division,and modulus.</td>

</tr>
<tr valign="top">
<td>+ -</td>
<td valign="bottom">Addition and subtraction.</td>

</tr>
<tr valign="top">
<td>space</td>
<td valign="bottom">String concatenation.</td>

(编辑:晋中站长网)

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

Description
Description