Selecting a paragraph with first line known
/^first line content$/,/^$/
works in both AWK and sed for addressing a paragraph, or any content with unique start and end identifiers.
sed -i -e '/^Package: angie-module-wasmtime$/,/^$/d' debian/control
Perl paragraph mode
-00
is a special value that cause Perl to slurp files in paragraph mode. This is very useful if we need to match text in the middle of a paragraph, which is more difficult for a line-oriented editor like sed.
perl -i -00 -ne 'print unless /wasmtime/' debian/rules
In AWK, you could use -v RS=
to read inputs in paragraph, but you will also need -v ORS='\n\n'
to set the output separator.
Note that both Perl paragraph mode and AWK’s -v RS=
rewrites the output separators, so if your file has more than three consecutive newlines, they will be rewritten.