sed 正则 ! 取反

!符号表示取反,x,y!表示匹配不在x和y行号范围内的行,利用sed命令用于的阿银不在2-7之间的行

[111 sed]$ cat input 
1
2
3
4
5
6
7
8
9
10
[111 sed]$ sed -n '2,7!p' input 
1
8
9
10

x!表示匹配除了x行号外的所有行,但是,!符号不能用于关键字匹配,

[111 sed]$ sed -n '7!p' input   
1
2
3
4
5
6
8
9
10
原文地址:https://www.cnblogs.com/nb-blog/p/10373286.html