森 • 时光机

sed 替换两行之间的内容

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 ##

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »