用于匹配列值的shell脚本,并使用第一个匹配行计算行数

时间:2017-03-12 22:34:13

标签: shell

示例文件:list.txt

ABC|DEF|March11,2017|11:00|1
ABC|DEF|March11,2017|11:10|1
ABC|DEF|March11,2017|11:20|0
DEF|TRO|March11,2017|11:30|0
DEF|TRO|March11,2017|11:40|1
DEF|TRO|March11,2017|11:50|0
RFR|TRO|March11,2017|12:00|0
DAEF|TRO|March11,2017|12:10|4
DSDEF|TRO|March11,2017|12:20|2
DScEF|TRO|March11,2017|12:30|1
DCDEF|TRO|March11,2017|12:40|0
DE34F|TRO|March11,2017|12:50|0
DESDF|TRO|March11,2017|13:00|0

我想计算$5位置ne 0的行,直到$5变为0,方法是打印shell中的第一个匹配行($0

Ex:o / p应为

ABC|DEF|March11,2017|11:00|1 - 2(rows) 
DEF|TRO|March11,2017|11:40|1 - 1 (rows)
DAEF|TRO|March11,2017|12:10|4 - 3(rows)

0 个答案:

没有答案