sedを使用してdhcp設定ファイルからブロックを削除してもらえますか?私は回路-idで一致したホストのためのブロックを削除する必要がありsed delete block
host dev1 {
host-identifier option agent.circuit-id "test1:418";
fixed-address xxx.xxx.xxx.xxx;
option routers xxx.xxx.xxx.xxx;
option subnet-mask xxx.xxx.xxx.xxx;
}
host host2{
host-identifier option agent.circuit-id "test2-:5";
fixed-address xxx.xxx.xxx.xxx;
option routers xxx.xxx.xxx.xxx;
option subnet-mask xxx.xxx.xxx.xxx;
}
: ファイルは次のようになります。
sed -e '/^host\s*\S*\s*{\s*/ { N; /\s*test1:418/ { N; /[^host]/ { N; /[^host]/ { N; /[^host]/ { N; /[^host]/d}}}}}' -e '/^$/d' /path/to/file
しかし、それは...全く許容いないようです:(
'[^ host]'は 'h'、' o'、 's'、' t'以外の一文字にマッチします。あなたのサンプルのすべての行には、少なくとも1つの文字が含まれています。したがって、すべての行はこの条件に一致します。 – tripleee
多くの 'sed'方言も' \ s'などのPerl拡張をサポートしていません – tripleee