标题: sed的模板确定范围内的被打印无法理解 [打印本页] 作者: 木木老蔫 时间: 2012-12-05 17:26 标题: sed的模板确定范围内的被打印无法理解 sed -n '/test/,/check/p' example-----所有在模板test和check所确定的范围内的行都被打印。
上面是例子
如果我example里面是
a 2 b 3 c 4
ab 8 b 6 c 7
c 5 d 2 b 1
我的命令是
sed -n '/a/,/b/p' a.txt
会发现第三行没被打印出来
求解作者: cuteorange 时间: 2012-12-05 17:29 回复 1# 木木老蔫
range operator maintains its own Boolean state.
It is false as long as its left operand is false. Once the left operand is true, the range operator stays true until the right operand is true, after which the range operator becomes false again.
The operator doesn't become false until the next time it is evaluated.作者: 木木老蔫 时间: 2012-12-05 17:55
是不是第三轮啊,每行都要匹配?回复 2# cuteorange