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

awk - Unix, Linux Command---reference

发布时间:2021-01-26 15:34:41 所属栏目: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-

This function is provided and documented in?GAWK: Effective AWK Programming,but everything about this feature is likely to change in the next release. We STRONGLY recommend that you do not use this feature for anything that you aren’t willing to redo.

pgawk?accepts two signals.?SIGUSR1?causes it to dump a profile and function call stack to the profile file,which is either?awkprof.out,or whatever file was named with the?--profile?option. It then continues to run.?SIGHUP?causes it to dump the profile and function call stack and then exit.

Print and sort the login names of all users:

????????BEGIN???{ FS = ":" } ????????????????{ print $1 | "sort" }

Count lines in a file:

????????????????{ nlines++ } ????????END?????{ print nlines }

Precede each line by its number in the file:

????????{ print FNR,$0 }

Concatenate and line number (a variation on a theme):

????????{ print NR,$0 } Run an external command for particular lines of data:

????????tail -f access_log | ????????awk ’/myhome.html/ { system("nmap " $1 ">> logdir/myhome.html") }’

String constants are sequences of characters enclosed in double quotes. In non-English speaking environments,it is possible to mark strings in the?AWK?program as requiring translation to the native natural language. Such strings are marked in the?AWK?program with a leading underscore (‘‘_’’). For example,

gawk ’BEGIN { print "hello,world" }’

always prints?hello,world. But,

gawk ’BEGIN { print _"hello,world" }’

might print?bonjour,monde?in France.

There are several steps involved in producing and running a localizable?AWK?program.

? ?BEGIN { TEXTDOMAIN = "myprog" }

This allows?gawk?to find the?.mo?file associated with your program. Without this step,?gawk?uses the?messages?text domain,which likely does not contain translations for your program.

myprog.po?to generate a.po?file for your program.The internationalization features are described in full detail in?GAWK: Effective AWK Programming.

A primary goal for?gawk?is compatibility with the?POSIX?standard,as well as with the latest version of?UNIX?awk. To this end,?gawk?incorporates the following user visible features which are not described in the?AWK?book,but are part of the Bell Laboratories version of?awk,and are in the?POSIX?standard.

The book indicates that command line variable assignment happens when?awk?would otherwise open the argument as a file,which is after the?BEGIN?block is executed. However,in earlier implementations,when such an assignment appeared before any file names,the assignment would happen?before?the?BEGIN?block was run. Applications came to depend on this ‘‘feature.’’ When?awk?was changed to match its documentation,the?-v?option for assigning variables before program execution was added to accommodate applications that depended upon the old behavior. (This feature was agreed upon by both the Bell Laboratories and the?GNU?developers.)

The?-W?option for implementation specific features is from the?POSIX?standard.

(编辑:ASP站长)

【免责声明】本站内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

Description
相关内容
未处理完善
    无相关信息
未处理完善