Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在CentOS中使用bash脚本删除文件中的文本_Bash_Shell_Centos5 - Fatal编程技术网

在CentOS中使用bash脚本删除文件中的文本

在CentOS中使用bash脚本删除文件中的文本,bash,shell,centos5,Bash,Shell,Centos5,我是来自印度尼西亚的学生,我想创建一个脚本,从包含以下文本的文件中删除几行: zone "irf.com" { type master; file "db.irf.com"; allow-update { none; }; }; zone "friedrice.com" { type master; file "db.friedrice.com"; allow-update { none; }; }; zone "you.com" { type master; file "db.you.co

我是来自印度尼西亚的学生,我想创建一个脚本,从包含以下文本的文件中删除几行:

zone "irf.com" {
type master;
file "db.irf.com";
allow-update { none; };
};

zone "friedrice.com" {
type master;
file "db.friedrice.com";
allow-update { none; };
};

zone "you.com" {
type master;
file "db.you.com";
allow-update { none; };
};
如果我要删除此项:

zone "friedrice.com" {
type master;
file "db.friedrice.com";
allow-update { none; };
};
在终端中,我可以运行:
sh you.txt friedrice

shell编程中的语法如何

所有文本都在一个文件中,比如说
you.txt

我是个新手,所以请帮我使用这个:

sed -i -E -n '1h;1!H;${;g;s/zone "friedrice.com" {[^}]*};\n};//g;p;}' you.txt

可以给我你的电子邮件吗??所以我可以问你linux中的一些问题,非常感谢先生:)@achmadirfan:如果你还有其他问题,请在堆栈溢出上发布。请。。不要给你的配置或脚本文件命名
*.txt
…虽然你已经收到了一些关于你具体问题的好答案,但它们相当于使用非结构化工具来处理结构化数据。您有区域数据,而不是XML,但这是一个细节;从根本上讲,这与我们的问题是一样的
sed -i '/^zone "friedrice.com"/,/^}/d' you.txt