Sed命令详解
sed定位文件位置
Sed 支持以下几种地址类型:
1、first~step
这两个单词的意思:first 指起始匹配行,step 指步长,例如:sed -n 2~5p 含义:从第二行开始匹配,隔 5 行匹配一次,即 2,7,12.......。
2、$
这个$符表示匹配最后一行。
3、 /REGEXP/
这个是表示匹配正则那一行,通过//之间的正则来匹配。
4、 cREGEXPc
这个是表示匹配正则那一行,通过c 和 c 之间的正则来匹配,c 可以是任一字符
5、 addr1, add2
定址 addr1, add2 决定用于对哪些行进行编辑。地址的形式可以是数字、正则表达式或二者的结合。如果没有指定地址, sed 将处理输入文件中的所有行。如果定址是一个数字,则这个数字代表行号,如果是逗号分隔的两个行号,那么需要处理的定址就是两行之间的范围(包括两行在内)。范围可以是数字,正则或二者组合。
6、 addr1, +N
从 addr1 这行到往下 N 行匹配,总共匹配 N+1 行
https://www.cnblogs.com/ginvip/p/6376049.html