对于给定的字符串,将倒数第3个he替换成M,并且仅打印被替换操作改变了的行:echo 'he and she here head and ache' | sed -nr '_______________________'he and she Xre head and ache
查看答案
仅打印文件hello.txt的第3行,并用-----上下包围该行:$ sed -ne _____________ hello.txt-----This game is good-----
对文件 hello.txt,把从包含"you"的行开始一直到文件结尾整个替换为"\nHave a nice day"$ sed -e '_______________________' hello.txtHello WorldHave a nice day
把所有偶数行替换为---seq 5 | sed '__________'1---3---5
在文件foo.txt的每两行之后添加来自文件address.txt的一行内容$ cat foo.txtbla bla 2015 blablah 2018 blahbla bla blacopyright: 2020$ cat address.txtstart address: 0xA0, func1 address: 0xA0end address: 0xFF, func2 address: 0xB0$ sed -n 'p' address.txt | sed -e '________________' foo.txtbla bla 2015 blablah 2018 blahstart address: 0xA0, func1 address: 0xA0bla bla blacopyright: 2020end address: 0xFF, func2 address: 0xB0