1

私はインドネシアの学生で、次のテキストを含むファイルから数行を削除するスクリプトを作成したいと考えています。

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

シェルプログラミングの構文はどうですか??

すべてのテキストがファイルにあるとしましょうyou.txt

私は初心者なので、助けてください

4

2 に答える 2

0

これを使って:

sed -i -E -n '1h;1!H;${;g;s/zone "friedrice.com" {[^}]*};\n};//g;p;}' you.txt
于 2012-07-01T06:48:11.660 に答える
0
sed -i '/^zone "friedrice.com"/,/^}/d' you.txt
于 2012-07-01T07:06:17.580 に答える