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

发表评论