man sed
Addresses
Sed commands can be given with no addresses, in which case the command will be executed for all input lines; with one address, in which case the command will only be executed for input lines which match that address; or with two addresses, in which case the command will be executed for all input lines which match the inclusive range of lines starting from the first address and continuing to the second address. Three things to note about address ranges: the syntax is addr1,addr2 (i.e., the addresses are separated by a comma); the line which addr1 matched will always be accepted, even if addr2 selects an earlier line; and if addr2 is a regexp, it will not be tested against the line that addr1 matched.删除档内第 10 行到含 "man" 字串的资料行 , 则指令为 10,/man/d
/apple/,/orange/d 其表示删除资料区 , 由档内含有 "apple" 字串至含有 "orange" 字串的资料行
ps.
sed命令还可以用大括号进行分组,使其作用于同一个地址:
[address]{
command1
command2
command3
}
或
[address]{command1;command2;command3}
awk和sed 格式类似
ref:
http://doc.linuxpk.com/351.html
http://blog.csdn.net/ShowMan/archive/2009/07/31/4396142.aspx
http://hi.baidu.com/stroot/blog/item/1f4f420970f390aa2fddd40f.html
http://www.blogjava.net/alwayscy/archive/2009/09/01/293409.html