- 论坛徽章:
- 3
|
回复 1# siyecaoliu
1.参见sed的manual
0,/regexp/
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.
Note that this is the only place where the 0 address makes sense; there is no 0-th line and commands which are given the 0 address in any other way will give an error.
2.因为你用的是add,/regex/的形式,那么在替换时没有搜索内容的。如果用的是/regex/,/regex2/或者/regex/那么是可以的。
3. 1,/D/是从第一行到第一个含有D的那一行。 注意跟/regex/,/regex2/区分,如果这儿用的是/d/,/D/那么后面的/D/表示匹配到最后一个包含D的那一行。
|
|