测试文本内容如下:
aaa
Completed in 21
bbbb
Completed in 22
cccc
Completed in 23
dddd
Completed in 24
需求:当complete后面的值大于20 取上一个complete到当前complete之间的数据
执行代码如下:
- #!/bin/awk -f
- {
- arr[NR]=$0
- }
- $0 ~ /Completed/{
- if($3>20){
- for (i in arr)
- print arr[i]
- delete arr
- }
- else
- delete arr
- }
阅读(3999) | 评论(0) | 转发(3) |