如果示例中引号后的第一个符号是点,我需要从配置中删除每一行:
local-zone: ".test.com" redirect <- remove
local-zone: "www.test.com" redirect <- don't remove
local-zone: "test.com" redirect <- don't remove
我尝试过使用 sed 但没有成功:
sed -i '/".*\..*"/d' file.txt
答案1
如果你有sed
,你grep
也有;)
$ grep -Ev '"\.[^"]+"' file .txt | sponge file.txt
local-zone: "www.test.com" redirect <- don't remove
local-zone: "test.com" redirect <- don't remove
和sed
:
$ sed -i -E '/"\.[^"]+"/d' file
local-zone: "www.test.com" redirect <- don't remove
local-zone: "test.com" redirect <- don't remove