打印某行到某行之間的內容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]
參考:數字