sed 替换两行之间的内容

2024-03-09T09:06:14
wshon@thinkbook:~$ cat hosts2
123456
234567
## Ghs ##
asd
asd
## Ghe ##
wshon@thinkbook:~$ sed -i '/## Ghs ##/,/## Ghe ##/{d}' hosts2
wshon@thinkbook:~$ cat hosts2
123456
234567
wshon@thinkbook:~$ cp hosts hosts2
wshon@thinkbook:~$ sed -i '/## Ghs ##/,/## Ghe ##/{/## Ghs ##/!{/## Ghe ##/!d}}' hosts2
wshon@thinkbook:~$ cat hosts2
123456
234567
## Ghs ##
## Ghe ##
当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »