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

awk - Unix, Linux Command---reference

发布时间:2020-05-24 08:09:35 所属栏目:Linux 来源:互联网
导读:http://www.tutorialspoint.com/unix_commands/awk.htmNAMEgawk - pattern scanning and processing langua

http://www.tutorialspoint.com/unix_commands/awk.htm

gawk - pattern scanning and processing language

gawk[POSIXorGNUstyle options ]-fprogram-file[--] file ...gawk[POSIXorGNUstyle options ] [--]program-textfile ...

pgawk[POSIXorGNUstyle options ]-fprogram-file[--] file ...pgawk[POSIXorGNUstyle options ] [--]program-textfile ...

Gawkis theGNUProject’s implementation of theAWKprogramming language. It conforms to the definition of the language in thePOSIX1003.2 Command Language And Utilities Standard. This version in turn is based on the description inThe AWK Programming Language,by Aho,Kernighan,and Weinberger,with the additional features found in the System V Release 4 version ofUNIXawk.Gawkalso provides more recent Bell Laboratoriesawkextensions,and a number ofGNU-specific extensions.

Pgawkis the profiling version ofgawk. It is identical in every way togawk,except that programs run more slowly,and it automatically produces an execution profile in the fileawkprof.outwhen done. See the--profileoption,below.

The command line consists of options togawkitself,theAWKprogram text (if not supplied via the-for--fileoptions),and values to be made available in theARGCandARGVpre-definedAWKvariables.

Gawkoptions may be either traditionalPOSIXone letter options,orGNUstyle long options.POSIXoptions start with a single ‘‘-’’,while long options start with ‘‘--’’. Long options are provided for bothGNU-specific features and forPOSIX-mandated features.

Following thePOSIXstandard,gawk-specific options are supplied via arguments to the-Woption. Multiple-Woptions may be supplied Each-Woption has a corresponding long option,as detailed below. Arguments to long options are either joined with the option by an=sign,with no intervening spaces,or they may be provided in the next command line argument. Long options may be abbreviated,as long as the abbreviation remains unique.

Gawkaccepts the following options,listed alphabetically.

fs--field-separatorfsfsfor the input field separator (the value of theFSpredefined variable).</tr>
<tr valign="top">
<td colspan="2">
-vvar=val--assignvar=val
</td>

</tr>
<tr valign="top">
<td width="6%"></td>
<td>Assign the valuevalto the variablevar,before execution of the program begins. Such variable values are available to theBEGINblock of anAWKprogram.</td>

</tr>
<tr valign="top">
<td colspan="2">
-fprogram-file--fileprogram-file
</td>

</tr>
<tr valign="top">
<td width="6%"></td>
<td>Read theAWKprogram source from the fileprogram-file,instead of from the first command line argument. Multiple-f(or--file) options may be used.</td>

</tr>
<tr valign="top">
<td>
-mfNNN-mrNNN
</td>
<td valign="bottom">Set various memory limits to the valueNNN. Thefflag sets the maximum number of fields,and therflag sets the maximum record size. These two flags and the-moption are from the Bell Laboratories research version ofUNIXawk. They are ignored bygawk,sincegawkhas no pre-defined limits.</td>

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

</tr>
<tr valign="top">
<td width="6%"></td>
<td>Run incompatibilitymode. In compatibility mode,gawkbehaves identically toUNIXawk; none of theGNU-specific extensions are recognized. The use of--traditionalis preferred over the other forms of this option. See<a href="http://www.tutorialspoint.com/#34"&gt;GNU EXTENSIONS,below,for more information.</td>

</tr>
<tr valign="top">
<td colspan="2">
-W copyleft-W copyright--copyleft--copyright
</td>

</tr>
<tr valign="top">
<td width="6%"></td>
<td>Print the short version of theGNUcopyright information message on the standard output and exit successfully.</td>

</tr>
<tr valign="top">
<td colspan="2">
-W dump-variables[=file]--dump-variables[=file]</td>

</tr>
<tr valign="top">
<td width="6%"></td>
<td>Print a sorted list of global variables,their types and final values tofile. If nofileis provided,gawkuses a file namedawkvars.outin the current directory.

Having a list of all the global variables is a good way to look for typographical errors in your programs. You would also use this option if you have a large program with a lot of functions,and you want to be sure that your functions don’t inadvertently use global variables that you meant to be local. (This is a particularly easy mistake to make with simple variable names likei,j,and so on.)

</td>

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

</tr>
<tr valign="top">
<td width="6%"></td>
<td>Similar to-f,however,this is option is the last one processed. This should be used with#!scripts,particularly for CGI applications,to avoid passing in options or source code (!) on the command line from a URL. This option disables command-line variable assignments.</td>

</tr>
<tr valign="top">
<td>
-W gen-po--gen-po
</td>
<td valign="bottom">Scan and parse theAWKprogram,and generate aGNU.poformat file on standard output with entries for all localizable strings in the program. The program itself is not executed. See theGNUgettextdistribution for more information on.pofiles.</td>

</tr>
<tr valign="top">
<td>
-W help-W usage--help--usage
</td>
<td valign="bottom">Print a relatively short summary of the available options on the standard output. (Per theGNU Coding Standards,these options cause an immediate,successful exit.)</td>

</tr>
<tr valign="top">
<td colspan="2">
-W lint[=value]--lint[=value]</td>

</tr>
<tr valign="top">
<td width="6%"></td>
<td>Provide warnings about constructs that are dubious or non-portable to otherAWKimplementations. With an optional argument offatal,lint warnings become fatal errors. This may be drastic,but its use will certainly encourage the development of cleanerAWKprograms. With an optional argument ofinvalid,only warnings about things that are actually invalid are issued. (This is not fully implemented yet.)</td>

</tr>
<tr valign="top">
<td colspan="2">
-W lint-old--lint-old
</td>

</tr>
<tr valign="top">
<td width="6%"></td>
<td>Provide warnings about constructs that are not portable to the original version of Unixawk.</td>

</tr>
<tr valign="top">
<td colspan="2">
-W non-decimal-data--non-decimal-data
</td>

</tr>
<tr valign="top">
<td width="6%"></td>
<td>Recognize octal and hexadecimal values in input data.Use this option with great caution!
</td>

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

(编辑:安卓应用网)

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

Description