打印某行到某行之间的内容code
sed '/xxx/,/yyy/'p -n txt字符串
[root@ax-01 ~]# cat test ert fff ** [abcfd] 123 324 444 [rty] ** fgfgf [root@ax-01 ~]# sed '/abc/,/rty/'p -n test [abcfd] 123 324 444 [rty]
sed转换大小写get
首字母匹配 \bit
全行大写 \u upio
全行小写 \l littletest
[root@ax-01 ~]# cat txt cat dog [root@ax-01 ~]# sed s'/\b[a-z]/\u&/'g txt Cat Dog [root@ax-01 ~]# sed s'/[a-z]/\u&/'g txt CAT DOG [root@ax-01 ~]# sed s'/[a-z]/\u&/'g -i txt [root@ax-01 ~]# cat !$ cat txt CAT DOG [root@ax-01 ~]# sed s'/[A-Z]/\l&/'g txt cat dog
在某一行最后添加一个数字sed
[root@ax-01 ~]# sed s'/^.*$/& 6/' txt CAT 6 DOG 6
删除某行到最后一行co
[root@ax-01 ~]# sed '/abc/,$'d test ert fff **
打印1到100行含某个字符串的行 sed -n '1,100{/abc/p}' 1.txt字符
[root@ax-01 ~]# sed '3,8{/abc/p}' -n test [abcfd]
参考:数字