我有一個簡單sed的,我使用,以取代之間的一切(包括)//thistest.com--
和--thistest.com
與什麼(刪除塊一起)命令:爲什麼我的sed多行查找和替換不能按預期工作?
sudo sed -i "[email protected]//thistest\.com--.*--thistest\[email protected]@g" my.file
的my.file
內容是:
//thistest.com--
zone "awebsite.com" {
type master;
file "some.stuff.com.hosts";
};
//--thistest.com
由於我使用@
作爲我的分隔符正則表達式,我不需要逃避/
字符。我也正確(我認爲)在.com
轉義.
。所以我不確定究竟是什麼失敗。
爲什麼不是整個塊被替換?
Sed一次操作一行。你無法以這種方式匹配多行模式。 –