http://bbs.chinaunix.net/thread-3557086-1-2.html
CU论坛上面的题目上面链接地址。
昨天没搞懂主要是在看那个info sed 中上面那么一点点英文
然后刚刚有点懂了
jk@ck ~/spt> seq 6|sed -e '1,2d' -e '1,4d'
5
6
这个是我电脑上面的结果。我简单解释下,那个论坛上面已经解释的很清楚 了
第一次是把1,2 行删除,然后剩下3 4 5 6行,此时行号没有改变。
然后开始第二次的匹配第二次是从第一行删除的,但是第一行刚刚已经被删除了。现在的行号是3
但是在sed的说明书上面有那么一段就是这么说的.就是五楼贴的那个。
A line number of 0 can be used in an address specification like 0,/regexp/ so that sed will try to match regexp in the first input line too. In other words, 0,/regexp/ is similar to 1,/regexp/, except that if addr2 matches the very first line of input the 0,/regexp/ form will consider it to end the range,
看下面这一句。
whereas the 1,/regexp/ form will match the beginning of its range and hence make the range span up to the second occurrence of the regular expression.
最后一句就是说第一行肯定会匹配,不管要匹配的那个行号。
我个人认为是这样的。
如果有什么不对的地方请在下面留言。