awk or gawk (gnu awk)

awk的基本功能是在文件中搜索包含模式的行(或其他文本单元)。
当一行匹配时,awk会对该行执行特定操作。

假设我们有一个文件,假设该文件包含“Audrey 5550164”这一行。
在AWK中,第一个字段称为$1,第二个字段称为$2,依此类推。
因此,用于检索Audrey电话号码的AWK程序是:
awk ‘$1 == “Audrey” {print $2}’ numbers.txt
这意味着如果第一个字段与Audrey匹配,则打印第二个字段。

在awk中,$0是整个参数。

实例

从ls -l列表中,从输出的每一行返回第五项($5):

$ ls -l | awk '{print $5}'

打印行号(NR),samplefile.txt中每行的第一项($1):

$ awk '{print NR "- " $1 }' samplefile.txt

打印第一项(1),然后打印samplefile.txt中每行的第三项(NF-2):

$ awk '{print $1, $(NF-2) }' samplefile.txt

打印至少包含一个字段的每一行。这是一种从文件中删除空白行的简单方法(或者更确切地说,
创建一个类似于旧文件的新文件,但删除了空白行)

awk 'NF > 0' data.txt

grep比较:

针对以下文件列表运行grep Dec将返回以粗体显示的3行,因为它与不同位置的文本匹配

-rw-r--r-- 7 simon simon 12043 Jan 31 09:36 December.pdf
-rw-r--r-- 3 simon simon 1024 Dec 01 11:59 README
-rw-r--r-- 3 simon simon 5096 Nov 14 18:22 Decision.txt

对同一文件列表运行awk'$ 6 ==“Dec”',关系运算符$ 6匹配确切字段(第6列=月),因此它将仅列出12月文件:

$ ls -l /tmp/demo | awk '$6 == "Dec"'

打印最长输入行的长度:

awk '{ if (length($0) > max) max = length($0) }
  END { print max }' data

打印从0到100的七个随机数,包括:

awk 'BEGIN { for (i = 1; i <= 7; i++)
            print int(101 * rand()) }'

打印FILES使用的总字节数:

ls -lg FILES | awk '{ x += $5 } ; END { print "total bytes: " x }'

打印目录中所有.PNG文件的平均文件大小:

ls -l *.png | gawk '{sum += $5; n++;} END {print sum/n;}' 

打印所有用户的登录名的排序列表:

 awk -F: '{ print $1 }' /etc/passwd | sort

计算文件中的行数:

awk 'END { print NR }' data

在数据文件中打印偶数行。如果您使用表达式’NR%2 == 1’,它将打印奇数行.

 awk 'NR % 2 == 0' data

语法

  awk <options> 'Program' Input-File1 Input-File2 ...

  awk -f PROGRAM-FILE <options> Input-File1 Input-File2 ...

选项

-F FS
--field-separator FS
   为输入字段分隔符使用FS(FS预定义变量的值)

-f PROGRAM-FILE
--file PROGRAM-FILE
   从文件程序文件中读取AWK程序源,而不是从第一条命令行参数读取

-mf NNN
-mr NNN
    “f”标志设置字段的最大数量,而“R”标志设置最大记录大小。
    这些选项被“gawk”忽略了,因为“gawk”没有预先定义的限制;
    它们只是为了与贝尔实验室研究版本的Unix awk兼容

-v VAR=VAL
--assign VAR=VAL
 在程序执行开始之前分配变量VAR值VAL.

-W traditional
-W compat
--traditional
--compat
    使用兼容模式,其中“GAWK”扩展关闭。

 -W lint
 --lint
    给出可疑或不可移植的AWK结构的警告

 -W lint-old
 --lint-old
    警告AWK原始版本7 UNIX版本中不可用的构造

 -W posix
 --posix
  使用POSIX兼容模式,其中“GAWK”扩展关闭,并应用其他限制。

 -W re-interval
 --re-interval
   允许区间表达式,在正则表达式中。

 -W source=PROGRAM-TEXT
 --source PROGRAM-TEXT
     使用程序文本作为AWK程序源代码。
     此选项允许将命令行源代码与文件中的源代码混合,
     并且特别适用于将命令行程序与库函数混合。

为了便于阅读,awk程序中的每一行通常都是一个单独的Program语句,如下所示:

 pattern { action }
 pattern { action }
 ...

例如,显示包含字符串“123”或“abc”或“some text”的samplefile中的行:

 awk '/123/ { print $0 } 
      /abc/ { print $0 }
      /some text/ { print $0 }' samplefile

用斜杠(/)括起来的正则表达式是一个awk模式,它匹配其文本属于该集合的每个输入记录。例如,pattern/foo/匹配记录中包含三个字符foo,* anywhere *的任何输入记录

awk模式可以是以下之一:

/Regular Expression/        - Match =
Pattern && Pattern          - AND
Pattern || Pattern          - OR
! Pattern                   - NOT
Pattern ? Pattern : Pattern - If, Then, Else
Pattern1, Pattern2          - Range Start - end
BEGIN                       - Perform action BEFORE input file is read
END                         - Perform action AFTER input file is read

具有特殊含义的变量名称:

 CONVFMT  转换数字时使用的CONVFMT转换格式
          (默认 %.6g)

 FS       用于分隔字段的FS正则表达式; 也可以
          通过选项-Ffs进行设置.

 NF       当前记录中的字段

 NR       当前记录的序号

 FNR      文件中当前记录的序号

 FILENAME 当前输入文件的名称

 RS       输入记录分隔符(默认换行)

 OFS      输出字段分隔符(默认为空白)

 ORS      输出记录分隔符(默认换行)

 OFMT     数字输出格式 (默认 %.6g)

 SUBSEP   分隔多个下标 (默认 034)

 ARGC     参数计数,可分配

 ARGV     参数数组,可分配; 非null被
          视为文件名

 ENVIRON  环境变量数组,下标是
          名称.

除了简单的模式匹配,awk还有大量的文本和算术函数,变量和运算符

在以下任何一种情况下,“gawk”将忽略换行符:

, { ? : || && do else

awk 命令实例:

linux命令:awk {'print rshift(and($1, 0xFF000000), 24) "." rshift(and($1, 0x00FF0000), 16) "." rshift(and($1, 0x0000FF00), 8) "." and($1, 0x000000FF)'} 0x000000FF)'} and($1, "." 8) 0x0000FF00), rshift(and($1, "." 16) 0x00FF0000), rshift(and($1, "." 24) 0xFF000000), rshift(and($1, {'print awk awk {'print rshift(and($1, 0xFF000000), 24) "." rshift(and($1, 0x00FF0000), 16) "." rshift(and($1, 0x0000FF00), 8) "." and($1, 0x000000FF)'}rootopen.com
linux命令:awk {'print rshift(and($1, 0xFF000000), 24) "." rshift(and($1, 0x00FF0000), 16) "." rshift(and($1, 0x0000FF00), 8) "." and($1, 0x000000FF)'} 0x000000FF)'} and($1, "." 8) 0x0000FF00), rshift(and($1, "." 16) 0x00FF0000), rshift(and($1, "." 24) 0xFF000000), rshift(and($1, {'print awk awk {'print rshift(and($1, 0xFF000000), 24) "." rshift(and($1, 0x00FF0000), 16) "." rshift(and($1, 0x0000FF00), 8) "." and($1, 0x000000FF)'}rootopen.com
2018-08-19 23:13:32

linux命令:awk '{ FS = OFS = "#" } { if ($9==1234) print }' filename*.log > bigfile.log bigfile.log > filename*.log }' print ($9==1234) if { } "#" = OFS = FS '{ awk awk '{ FS = OFS = "#" } { if ($9==1234) print }' filename*.log > bigfile.logrootopen.com
linux命令:awk '{ FS = OFS = "#" } { if ($9==1234) print }' filename*.log > bigfile.log bigfile.log > filename*.log }' print ($9==1234) if { } "#" = OFS = FS '{ awk awk '{ FS = OFS = "#" } { if ($9==1234) print }' filename*.log > bigfile.logrootopen.com
2018-05-10 04:58:48

linux命令:awk '{count[length]++}END{for(i in count){printf("%d: %d\n", count[i], i)}}' i)}}' count[i], %d\n", count){printf("%d: in '{count[length]++}END{for(i awk awk '{count[length]++}END{for(i in count){printf("%d: %d\n", count[i], i)}}'rootopen.com
linux命令:awk '{count[length]++}END{for(i in count){printf("%d: %d\n", count[i], i)}}' i)}}' count[i], %d\n", count){printf("%d: in '{count[length]++}END{for(i awk awk '{count[length]++}END{for(i in count){printf("%d: %d\n", count[i], i)}}'rootopen.com
2017-12-28 08:50:48

linux命令:awk 'length($0)!=12 {print}' your_file_name your_file_name {print}' 'length($0)!=12 awk awk 'length($0)!=12 {print}' your_file_namerootopen.com
linux命令:awk 'length($0)!=12 {print}' your_file_name your_file_name {print}' 'length($0)!=12 awk awk 'length($0)!=12 {print}' your_file_namerootopen.com
2018-05-23 14:11:48

linux命令:awk '/pattern1/ && /pattern2/ && !/pattern3/ {print}' {print}' !/pattern3/ && /pattern2/ && '/pattern1/ awk awk '/pattern1/ && /pattern2/ && !/pattern3/ {print}'rootopen.com
linux命令:awk '/pattern1/ && /pattern2/ && !/pattern3/ {print}' {print}' !/pattern3/ && /pattern2/ && '/pattern1/ awk awk '/pattern1/ && /pattern2/ && !/pattern3/ {print}'rootopen.com
2018-02-02 13:23:48

linux命令:awk '{if (NR % 2 == 0) print $0}' file.txt file.txt $0}' print 0) == 2 % (NR '{if awk awk '{if (NR % 2 == 0) print $0}' file.txtrootopen.com
linux命令:awk '{if (NR % 2 == 0) print $0}' file.txt file.txt $0}' print 0) == 2 % (NR '{if awk awk '{if (NR % 2 == 0) print $0}' file.txtrootopen.com
2018-04-26 13:43:48

linux命令:awk '{if (NR % 2 == 1) print $0}' file.txt file.txt $0}' print 1) == 2 % (NR '{if awk awk '{if (NR % 2 == 1) print $0}' file.txtrootopen.com
linux命令:awk '{if (NR % 2 == 1) print $0}' file.txt file.txt $0}' print 1) == 2 % (NR '{if awk awk '{if (NR % 2 == 1) print $0}' file.txtrootopen.com
2018-04-07 04:51:48

linux命令:awk '!_[$0]++{print}' '!_[$0]++{print}' awk awk '!_[$0]++{print}'rootopen.com
linux命令:awk '!_[$0]++{print}' '!_[$0]++{print}' awk awk '!_[$0]++{print}'rootopen.com
2018-01-13 15:00:48

linux命令:awk -F'^"|", "|"$' '{ print $2,$3,$4 }' file.csv file.csv }' $2,$3,$4 print '{ "|"$' -F'^"|", awk awk -F'^"|", "|"$' '{ print $2,$3,$4 }' file.csvrootopen.com
linux命令:awk -F'^"|", "|"$' '{ print $2,$3,$4 }' file.csv file.csv }' $2,$3,$4 print '{ "|"$' -F'^"|", awk awk -F'^"|", "|"$' '{ print $2,$3,$4 }' file.csvrootopen.com
2018-02-22 07:24:48

linux命令:awk 'BEGIN {FS=","} {loc = $4, val=$5; getline < "f0001ch1.csv"; print loc,val,$5}' f0001ch2.csv > data data > f0001ch2.csv loc,val,$5}' print "f0001ch1.csv"; < getline val=$5; $4, = {loc {FS=","} 'BEGIN awk awk 'BEGIN {FS=","} {loc = $4, val=$5; getline < "f0001ch1.csv"; print loc,val,$5}' f0001ch2.csv > datarootopen.com
linux命令:awk 'BEGIN {FS=","} {loc = $4, val=$5; getline < "f0001ch1.csv"; print loc,val,$5}' f0001ch2.csv > data data > f0001ch2.csv loc,val,$5}' print "f0001ch1.csv"; < getline val=$5; $4, = {loc {FS=","} 'BEGIN awk awk 'BEGIN {FS=","} {loc = $4, val=$5; getline < "f0001ch1.csv"; print loc,val,$5}' f0001ch2.csv > datarootopen.com
2018-06-07 03:17:48

linux命令:awk -F "=| " " "=| -F awk awk -F "=| "rootopen.com
linux命令:awk -F "=| " " "=| -F awk awk -F "=| "rootopen.com
2018-02-12 01:38:48

linux命令:awk '{ for (f = 1; f <= NF; f++) a[NR, f] = $f } NF > nf { nf = NF } END { for (f = 1; f <= nf; f++) for (r = 1; r <= NR; r++) printf a[r, f] (r==NR ? RS : FS) }' }' FS) : RS ? (r==NR f] a[r, printf r++) NR; <= r 1; = (r for f++) nf; <= f 1; = (f for { END } NF = nf { nf > NF } $f = f] a[NR, f++) NF; <= f 1; = (f for '{ awk awk '{ for (f = 1; f <= NF; f++) a[NR, f] = $f } NF > nf { nf = NF } END { for (f = 1; f <= nf; f++) for (r = 1; r <= NR; r++) printf a[r, f] (r==NR ? RS : FS) }'rootopen.com
linux命令:awk '{ for (f = 1; f <= NF; f++) a[NR, f] = $f } NF > nf { nf = NF } END { for (f = 1; f <= nf; f++) for (r = 1; r <= NR; r++) printf a[r, f] (r==NR ? RS : FS) }' }' FS) : RS ? (r==NR f] a[r, printf r++) NR; <= r 1; = (r for f++) nf; <= f 1; = (f for { END } NF = nf { nf > NF } $f = f] a[NR, f++) NF; <= f 1; = (f for '{ awk awk '{ for (f = 1; f <= NF; f++) a[NR, f] = $f } NF > nf { nf = NF } END { for (f = 1; f <= nf; f++) for (r = 1; r <= NR; r++) printf a[r, f] (r==NR ? RS : FS) }'rootopen.com
2018-03-09 14:36:48

linux命令:awk '{sum1+=$1; sum2+=$2} END {print sum1/NR, sum2/NR}' file.dat file.dat sum2/NR}' sum1/NR, {print END sum2+=$2} '{sum1+=$1; awk awk '{sum1+=$1; sum2+=$2} END {print sum1/NR, sum2/NR}' file.datrootopen.com
linux命令:awk '{sum1+=$1; sum2+=$2} END {print sum1/NR, sum2/NR}' file.dat file.dat sum2/NR}' sum1/NR, {print END sum2+=$2} '{sum1+=$1; awk awk '{sum1+=$1; sum2+=$2} END {print sum1/NR, sum2/NR}' file.datrootopen.com
2018-04-09 13:39:48

linux命令:awk '{sum+=$1; sumsq+=$1*$1} END {print sqrt(sumsq/NR - (sum/NR)**2)}' file.dat file.dat (sum/NR)**2)}' - sqrt(sumsq/NR {print END sumsq+=$1*$1} '{sum+=$1; awk awk '{sum+=$1; sumsq+=$1*$1} END {print sqrt(sumsq/NR - (sum/NR)**2)}' file.datrootopen.com
linux命令:awk '{sum+=$1; sumsq+=$1*$1} END {print sqrt(sumsq/NR - (sum/NR)**2)}' file.dat file.dat (sum/NR)**2)}' - sqrt(sumsq/NR {print END sumsq+=$1*$1} '{sum+=$1; awk awk '{sum+=$1; sumsq+=$1*$1} END {print sqrt(sumsq/NR - (sum/NR)**2)}' file.datrootopen.com
2018-01-07 00:30:48

linux命令:awk '/start_pattern/,/stop_pattern/' file.txt file.txt '/start_pattern/,/stop_pattern/' awk awk '/start_pattern/,/stop_pattern/' file.txtrootopen.com
linux命令:awk '/start_pattern/,/stop_pattern/' file.txt file.txt '/start_pattern/,/stop_pattern/' awk awk '/start_pattern/,/stop_pattern/' file.txtrootopen.com
2018-03-09 10:45:48

linux命令:awk '{print > $3".txt"}' FILENAME FILENAME $3".txt"}' > '{print awk awk '{print > $3".txt"}' FILENAMErootopen.com
linux命令:awk '{print > $3".txt"}' FILENAME FILENAME $3".txt"}' > '{print awk awk '{print > $3".txt"}' FILENAMErootopen.com
2018-06-03 11:30:48

linux命令:awk '/sshd/ && /Failed/ {gsub(/invalid user/,""); printf "%-12s %-16s %s-%s-%s\n", $9, $11, $1, $2, $3}' /var/log/auth.log /var/log/auth.log $3}' $2, $1, $11, $9, %s-%s-%s\n", %-16s "%-12s printf user/,""); {gsub(/invalid /Failed/ && '/sshd/ awk awk '/sshd/ && /Failed/ {gsub(/invalid user/,""); printf "%-12s %-16s %s-%s-%s\n", $9, $11, $1, $2, $3}' /var/log/auth.logrootopen.com
linux命令:awk '/sshd/ && /Failed/ {gsub(/invalid user/,""); printf "%-12s %-16s %s-%s-%s\n", $9, $11, $1, $2, $3}' /var/log/auth.log /var/log/auth.log $3}' $2, $1, $11, $9, %s-%s-%s\n", %-16s "%-12s printf user/,""); {gsub(/invalid /Failed/ && '/sshd/ awk awk '/sshd/ && /Failed/ {gsub(/invalid user/,""); printf "%-12s %-16s %s-%s-%s\n", $9, $11, $1, $2, $3}' /var/log/auth.logrootopen.com
2018-03-12 11:21:48

linux命令:awk 'BEGIN {srand()} {print int(rand()*1000000) "\t" $0}' FILE | sort -n | cut -f 2- 2- -f cut | -n sort | FILE $0}' "\t" int(rand()*1000000) {print {srand()} 'BEGIN awk awk 'BEGIN {srand()} {print int(rand()*1000000) "\t" $0}' FILE | sort -n | cut -f 2-rootopen.com
linux命令:awk 'BEGIN {srand()} {print int(rand()*1000000) "\t" $0}' FILE | sort -n | cut -f 2- 2- -f cut | -n sort | FILE $0}' "\t" int(rand()*1000000) {print {srand()} 'BEGIN awk awk 'BEGIN {srand()} {print int(rand()*1000000) "\t" $0}' FILE | sort -n | cut -f 2-rootopen.com
2018-01-02 21:10:48

linux命令:awk -F\" '{print $4}' *.log | grep -v "eviljaymz\|\-" | sort | uniq -c | awk -F\ '{ if($1>500) print $1,$2;}' | sort -n -n sort | $1,$2;}' print if($1>500) '{ -F\ awk | -c uniq | sort | "eviljaymz\|\-" -v grep | *.log $4}' '{print -F\" awk awk -F\" '{print $4}' *.log | grep -v "eviljaymz\|\-" | sort | uniq -c | awk -F\ '{ if($1>500) print $1,$2;}' | sort -nrootopen.com
linux命令:awk -F\" '{print $4}' *.log | grep -v "eviljaymz\|\-" | sort | uniq -c | awk -F\ '{ if($1>500) print $1,$2;}' | sort -n -n sort | $1,$2;}' print if($1>500) '{ -F\ awk | -c uniq | sort | "eviljaymz\|\-" -v grep | *.log $4}' '{print -F\" awk awk -F\" '{print $4}' *.log | grep -v "eviljaymz\|\-" | sort | uniq -c | awk -F\ '{ if($1>500) print $1,$2;}' | sort -nrootopen.com
2018-04-07 19:12:48

linux命令:awk 'BEGIN{size=5} {mod=NR%size; if(NR<=size){count++}else{sum-=array[mod]};sum+=$1;array[mod]=$1;print sum/count}' file.dat file.dat sum/count}' if(NR<=size){count++}else{sum-=array[mod]};sum+=$1;array[mod]=$1;print {mod=NR%size; 'BEGIN{size=5} awk awk 'BEGIN{size=5} {mod=NR%size; if(NR<=size){count++}else{sum-=array[mod]};sum+=$1;array[mod]=$1;print sum/count}' file.datrootopen.com
linux命令:awk 'BEGIN{size=5} {mod=NR%size; if(NR<=size){count++}else{sum-=array[mod]};sum+=$1;array[mod]=$1;print sum/count}' file.dat file.dat sum/count}' if(NR<=size){count++}else{sum-=array[mod]};sum+=$1;array[mod]=$1;print {mod=NR%size; 'BEGIN{size=5} awk awk 'BEGIN{size=5} {mod=NR%size; if(NR<=size){count++}else{sum-=array[mod]};sum+=$1;array[mod]=$1;print sum/count}' file.datrootopen.com
2018-04-12 23:17:48

linux命令:awk 'BEGIN{srand()}{print rand(),$0}' SOMEFILE | sort -n | cut -d ' ' -f2- -f2- ' ' -d cut | -n sort | SOMEFILE rand(),$0}' 'BEGIN{srand()}{print awk awk 'BEGIN{srand()}{print rand(),$0}' SOMEFILE | sort -n | cut -d ' ' -f2-rootopen.com
linux命令:awk 'BEGIN{srand()}{print rand(),$0}' SOMEFILE | sort -n | cut -d ' ' -f2- -f2- ' ' -d cut | -n sort | SOMEFILE rand(),$0}' 'BEGIN{srand()}{print awk awk 'BEGIN{srand()}{print rand(),$0}' SOMEFILE | sort -n | cut -d ' ' -f2-rootopen.com
2018-01-30 21:39:48

linux命令:awk '/match/{print NR}' file file NR}' '/match/{print awk awk '/match/{print NR}' filerootopen.com
linux命令:awk '/match/{print NR}' file file NR}' '/match/{print awk awk '/match/{print NR}' filerootopen.com
2018-01-03 19:40:48

linux命令:awk '{print}' | espeak -v pt -stdin -stdin pt -v espeak | '{print}' awk awk '{print}' | espeak -v pt -stdinrootopen.com
linux命令:awk '{print}' | espeak -v pt -stdin -stdin pt -v espeak | '{print}' awk awk '{print}' | espeak -v pt -stdinrootopen.com
2018-03-16 19:21:48

linux命令:awk '/regex/{print x};{x=$0}' x};{x=$0}' '/regex/{print awk awk '/regex/{print x};{x=$0}'rootopen.com
linux命令:awk '/regex/{print x};{x=$0}' x};{x=$0}' '/regex/{print awk awk '/regex/{print x};{x=$0}'rootopen.com
2018-02-25 19:00:48

linux命令:awk '{c=split($0, s); for(n=1; n<=c; ++n) print s[n] }' INPUT_FILE > OUTPUT_FILE OUTPUT_FILE > INPUT_FILE }' s[n] print ++n) n<=c; for(n=1; s); '{c=split($0, awk awk '{c=split($0, s); for(n=1; n<=c; ++n) print s[n] }' INPUT_FILE > OUTPUT_FILErootopen.com
linux命令:awk '{c=split($0, s); for(n=1; n<=c; ++n) print s[n] }' INPUT_FILE > OUTPUT_FILE OUTPUT_FILE > INPUT_FILE }' s[n] print ++n) n<=c; for(n=1; s); '{c=split($0, awk awk '{c=split($0, s); for(n=1; n<=c; ++n) print s[n] }' INPUT_FILE > OUTPUT_FILErootopen.com
2017-12-25 17:42:48

linux命令:awk '{print NR": "$0; for(i=1;i<=NF;++i)print "\t"i": "$i}' "$i}' "\t"i": for(i=1;i<=NF;++i)print "$0; NR": '{print awk awk '{print NR": "$0; for(i=1;i<=NF;++i)print "\t"i": "$i}'rootopen.com
linux命令:awk '{print NR": "$0; for(i=1;i<=NF;++i)print "\t"i": "$i}' "$i}' "\t"i": for(i=1;i<=NF;++i)print "$0; NR": '{print awk awk '{print NR": "$0; for(i=1;i<=NF;++i)print "\t"i": "$i}'rootopen.com
2018-06-06 22:49:48

linux命令:awk /./ filename filename /./ awk awk /./ filenamerootopen.com
linux命令:awk /./ filename filename /./ awk awk /./ filenamerootopen.com
2018-04-23 12:58:48

linux命令:awk -F ',' '{ x = x + $4 } END { print x }' test.csv test.csv }' x print { END } $4 + x = x '{ ',' -F awk awk -F ',' '{ x = x + $4 } END { print x }' test.csvrootopen.com
linux命令:awk -F ',' '{ x = x + $4 } END { print x }' test.csv test.csv }' x print { END } $4 + x = x '{ ',' -F awk awk -F ',' '{ x = x + $4 } END { print x }' test.csvrootopen.com
2018-01-18 22:21:48

linux命令:awk < file.name '{ system("resolveip -s " $1) }' }' $1) " -s system("resolveip '{ file.name < awk awk < file.name '{ system("resolveip -s " $1) }'rootopen.com
linux命令:awk < file.name '{ system("resolveip -s " $1) }' }' $1) " -s system("resolveip '{ file.name < awk awk < file.name '{ system("resolveip -s " $1) }'rootopen.com
2018-05-25 23:21:48

linux命令:awk '!($0 in a) {a[$0];print}' file file {a[$0];print}' a) in '!($0 awk awk '!($0 in a) {a[$0];print}' filerootopen.com
linux命令:awk '!($0 in a) {a[$0];print}' file file {a[$0];print}' a) in '!($0 awk awk '!($0 in a) {a[$0];print}' filerootopen.com
2018-04-22 16:41:48

linux命令:awk '!a[$0]++' file file '!a[$0]++' awk awk '!a[$0]++' filerootopen.com
linux命令:awk '!a[$0]++' file file '!a[$0]++' awk awk '!a[$0]++' filerootopen.com
2018-02-20 23:29:48

linux命令:awk '{print $1}' /var/log/httpd/access_log | sort | uniq -c | sort -rnk1 | head -n 10 10 -n head | -rnk1 sort | -c uniq | sort | /var/log/httpd/access_log $1}' '{print awk awk '{print $1}' /var/log/httpd/access_log | sort | uniq -c | sort -rnk1 | head -n 10rootopen.com
linux命令:awk '{print $1}' /var/log/httpd/access_log | sort | uniq -c | sort -rnk1 | head -n 10 10 -n head | -rnk1 sort | -c uniq | sort | /var/log/httpd/access_log $1}' '{print awk awk '{print $1}' /var/log/httpd/access_log | sort | uniq -c | sort -rnk1 | head -n 10rootopen.com
2018-05-09 22:09:48

linux命令:awk '{print substr($0, index($0,$N))}' index($0,$N))}' substr($0, '{print awk awk '{print substr($0, index($0,$N))}'rootopen.com
linux命令:awk '{print substr($0, index($0,$N))}' index($0,$N))}' substr($0, '{print awk awk '{print substr($0, index($0,$N))}'rootopen.com
2018-02-21 21:18:48

linux命令:awk '/d.[0-9]/{print $4}' /proc/partitions /proc/partitions $4}' '/d.[0-9]/{print awk awk '/d.[0-9]/{print $4}' /proc/partitionsrootopen.com
linux命令:awk '/d.[0-9]/{print $4}' /proc/partitions /proc/partitions $4}' '/d.[0-9]/{print awk awk '/d.[0-9]/{print $4}' /proc/partitionsrootopen.com
2018-06-04 06:54:48

linux命令:awk 'BEGIN {a=1;b=1;for(i=0;i<'${NUM}';i++){print a;c=a+b;a=b;b=c}}' a;c=a+b;a=b;b=c}}' {a=1;b=1;for(i=0;i<'${NUM}';i++){print 'BEGIN awk awk 'BEGIN {a=1;b=1;for(i=0;i<'${NUM}';i++){print a;c=a+b;a=b;b=c}}'rootopen.com
linux命令:awk 'BEGIN {a=1;b=1;for(i=0;i<'${NUM}';i++){print a;c=a+b;a=b;b=c}}' a;c=a+b;a=b;b=c}}' {a=1;b=1;for(i=0;i<'${NUM}';i++){print 'BEGIN awk awk 'BEGIN {a=1;b=1;for(i=0;i<'${NUM}';i++){print a;c=a+b;a=b;b=c}}'rootopen.com
2018-02-26 16:11:48

linux命令:awk 'length>72' file file 'length>72' awk awk 'length>72' filerootopen.com
linux命令:awk 'length>72' file file 'length>72' awk awk 'length>72' filerootopen.com
2018-02-27 08:02:48

linux命令:awk '{avg += ($1 - avg) / NR;} END { print avg; }' }' avg; print { END NR;} / avg) - ($1 += '{avg awk awk '{avg += ($1 - avg) / NR;} END { print avg; }'rootopen.com
linux命令:awk '{avg += ($1 - avg) / NR;} END { print avg; }' }' avg; print { END NR;} / avg) - ($1 += '{avg awk awk '{avg += ($1 - avg) / NR;} END { print avg; }'rootopen.com
2018-05-24 19:09:48

linux命令:awk '{delta = $1 - avg; avg += delta / NR; mean2 += delta * ($1 - avg); } END { print sqrt(mean2 / NR); }' }' NR); / sqrt(mean2 print { END } avg); - ($1 * delta += mean2 NR; / delta += avg avg; - $1 = '{delta awk awk '{delta = $1 - avg; avg += delta / NR; mean2 += delta * ($1 - avg); } END { print sqrt(mean2 / NR); }'rootopen.com
linux命令:awk '{delta = $1 - avg; avg += delta / NR; mean2 += delta * ($1 - avg); } END { print sqrt(mean2 / NR); }' }' NR); / sqrt(mean2 print { END } avg); - ($1 * delta += mean2 NR; / delta += avg avg; - $1 = '{delta awk awk '{delta = $1 - avg; avg += delta / NR; mean2 += delta * ($1 - avg); } END { print sqrt(mean2 / NR); }'rootopen.com
2018-01-09 00:43:48

linux命令:awk '{$1=""; print}' print}' '{$1=""; awk awk '{$1=""; print}'rootopen.com
linux命令:awk '{$1=""; print}' print}' '{$1=""; awk awk '{$1=""; print}'rootopen.com
2018-02-13 08:35:48

linux命令:awk '{print length, $0;}' | sort -nr -nr sort | $0;}' length, '{print awk awk '{print length, $0;}' | sort -nrrootopen.com
linux命令:awk '{print length, $0;}' | sort -nr -nr sort | $0;}' length, '{print awk awk '{print length, $0;}' | sort -nrrootopen.com
2018-06-11 04:05:48

linux命令:awk '{print(substr($0,1,5))}' file file '{print(substr($0,1,5))}' awk awk '{print(substr($0,1,5))}' filerootopen.com
linux命令:awk '{print(substr($0,1,5))}' file file '{print(substr($0,1,5))}' awk awk '{print(substr($0,1,5))}' filerootopen.com
2018-03-04 03:49:48

linux命令:awk '{if (NR == 3) print}' <file> <file> print}' 3) == (NR '{if awk awk '{if (NR == 3) print}' <file>rootopen.com
linux命令:awk '{if (NR == 3) print}' <file> <file> print}' 3) == (NR '{if awk awk '{if (NR == 3) print}' <file>rootopen.com
2018-01-30 21:36:48

linux命令:awk 'FNR==5' <file> <file> 'FNR==5' awk awk 'FNR==5' <file>rootopen.com
linux命令:awk 'FNR==5' <file> <file> 'FNR==5' awk awk 'FNR==5' <file>rootopen.com
2018-01-05 06:57:48

linux命令:awk 'BEGIN{dir=DIR?DIR:ENVIRON["PWD"];l=split(dir,parts,"/");last="";for(i=1;i<l+1;i++){d=last"/"parts[i];gsub("//","/",d);system("ls -ld \""d"\"");last=d}}' \""d"\"");last=d}}' -ld 'BEGIN{dir=DIR?DIR:ENVIRON["PWD"];l=split(dir,parts,"/");last="";for(i=1;i<l+1;i++){d=last"/"parts[i];gsub("//","/",d);system("ls awk awk 'BEGIN{dir=DIR?DIR:ENVIRON["PWD"];l=split(dir,parts,"/");last="";for(i=1;i<l+1;i++){d=last"/"parts[i];gsub("//","/",d);system("ls -ld \""d"\"");last=d}}'rootopen.com
linux命令:awk 'BEGIN{dir=DIR?DIR:ENVIRON["PWD"];l=split(dir,parts,"/");last="";for(i=1;i<l+1;i++){d=last"/"parts[i];gsub("//","/",d);system("ls -ld \""d"\"");last=d}}' \""d"\"");last=d}}' -ld 'BEGIN{dir=DIR?DIR:ENVIRON["PWD"];l=split(dir,parts,"/");last="";for(i=1;i<l+1;i++){d=last"/"parts[i];gsub("//","/",d);system("ls awk awk 'BEGIN{dir=DIR?DIR:ENVIRON["PWD"];l=split(dir,parts,"/");last="";for(i=1;i<l+1;i++){d=last"/"parts[i];gsub("//","/",d);system("ls -ld \""d"\"");last=d}}'rootopen.com
2018-02-21 00:30:48

linux命令:awk 'BEGIN {for(i=1;i<=100;i++)sum+=i}; END {print sum}' /dev/null /dev/null sum}' {print END {for(i=1;i<=100;i++)sum+=i}; 'BEGIN awk awk 'BEGIN {for(i=1;i<=100;i++)sum+=i}; END {print sum}' /dev/nullrootopen.com
linux命令:awk 'BEGIN {for(i=1;i<=100;i++)sum+=i}; END {print sum}' /dev/null /dev/null sum}' {print END {for(i=1;i<=100;i++)sum+=i}; 'BEGIN awk awk 'BEGIN {for(i=1;i<=100;i++)sum+=i}; END {print sum}' /dev/nullrootopen.com
2018-03-28 15:59:48

linux命令:awk '/q=/{print $11}' /var/log/httpd/access_log.4 | awk -F 'q=' '{print $2}' | sed 's/+/ /g;s/%22/"/g;s/q=//' | cut -d "&" -f 1 1 -f "&" -d cut | /g;s/%22/"/g;s/q=//' 's/+/ sed | $2}' '{print 'q=' -F awk | /var/log/httpd/access_log.4 $11}' '/q=/{print awk awk '/q=/{print $11}' /var/log/httpd/access_log.4 | awk -F 'q=' '{print $2}' | sed 's/+/ /g;s/%22/"/g;s/q=//' | cut -d "&" -f 1rootopen.com
linux命令:awk '/q=/{print $11}' /var/log/httpd/access_log.4 | awk -F 'q=' '{print $2}' | sed 's/+/ /g;s/%22/"/g;s/q=//' | cut -d "&" -f 1 1 -f "&" -d cut | /g;s/%22/"/g;s/q=//' 's/+/ sed | $2}' '{print 'q=' -F awk | /var/log/httpd/access_log.4 $11}' '/q=/{print awk awk '/q=/{print $11}' /var/log/httpd/access_log.4 | awk -F 'q=' '{print $2}' | sed 's/+/ /g;s/%22/"/g;s/q=//' | cut -d "&" -f 1rootopen.com
2018-02-08 12:29:48

linux命令:awk '{print $1}' "/proc/modules" | xargs modinfo | awk '/^(filename|desc|depends)/' '/^(filename|desc|depends)/' awk | modinfo xargs | "/proc/modules" $1}' '{print awk awk '{print $1}' "/proc/modules" | xargs modinfo | awk '/^(filename|desc|depends)/'rootopen.com
linux命令:awk '{print $1}' "/proc/modules" | xargs modinfo | awk '/^(filename|desc|depends)/' '/^(filename|desc|depends)/' awk | modinfo xargs | "/proc/modules" $1}' '{print awk awk '{print $1}' "/proc/modules" | xargs modinfo | awk '/^(filename|desc|depends)/'rootopen.com
2018-01-15 06:00:48

linux命令:awk '/<link>/{gsub(/.*<link>|<\/link>.*/,"");print "<li><a href=\042"$0"\042> "t"</a>" } /<title>/{gsub(/.*<title>|<\/title>.*/,"");t=$0 }' file file }' /<title>/{gsub(/.*<title>|<\/title>.*/,"");t=$0 } "t"</a>" href=\042"$0"\042> "<li><a '/<link>/{gsub(/.*<link>|<\/link>.*/,"");print awk awk '/<link>/{gsub(/.*<link>|<\/link>.*/,"");print "<li><a href=\042"$0"\042> "t"</a>" } /<title>/{gsub(/.*<title>|<\/title>.*/,"");t=$0 }' filerootopen.com
linux命令:awk '/<link>/{gsub(/.*<link>|<\/link>.*/,"");print "<li><a href=\042"$0"\042> "t"</a>" } /<title>/{gsub(/.*<title>|<\/title>.*/,"");t=$0 }' file file }' /<title>/{gsub(/.*<title>|<\/title>.*/,"");t=$0 } "t"</a>" href=\042"$0"\042> "<li><a '/<link>/{gsub(/.*<link>|<\/link>.*/,"");print awk awk '/<link>/{gsub(/.*<link>|<\/link>.*/,"");print "<li><a href=\042"$0"\042> "t"</a>" } /<title>/{gsub(/.*<title>|<\/title>.*/,"");t=$0 }' filerootopen.com
2018-04-06 12:41:48

linux命令:awk 'NR==2 {print $1}' /proc/net/arp /proc/net/arp $1}' {print 'NR==2 awk awk 'NR==2 {print $1}' /proc/net/arprootopen.com
linux命令:awk 'NR==2 {print $1}' /proc/net/arp /proc/net/arp $1}' {print 'NR==2 awk awk 'NR==2 {print $1}' /proc/net/arprootopen.com
2018-01-15 19:18:48

linux命令:awk '/inet end/ {print $3}' <(ifconfig eth0) eth0) <(ifconfig $3}' {print end/ '/inet awk awk '/inet end/ {print $3}' <(ifconfig eth0)rootopen.com
linux命令:awk '/inet end/ {print $3}' <(ifconfig eth0) eth0) <(ifconfig $3}' {print end/ '/inet awk awk '/inet end/ {print $3}' <(ifconfig eth0)rootopen.com
2018-04-14 11:55:48

Linux的Bash命令行(A-Z排序)