awk 数值变量

awk文件 test.awk

功能:计算文件中有多少个空行

 

BEGIN{x=0}

/^$/ {x=x+1}

END{print "find "x" blank lines"}

 

待测试文件:test.in(2空行)

1111111

22222222

 

3333333333

44444444

 

55555555

 

测试:

awk -f test.awk test.in

 

结果:

find 2 blank lines

 

 

你可能感兴趣的:(测试)