I am very new to shell script.
How can I delete multiple lines when the pattern is matched and stop deleting until the first blank line is matched?
You can do this:
sed '/STARTING_PATTERN/,/^$/d' filename
This will select all the lines starting from STARTING_PATTERN
upto a blank line ^$
and then delete those lines.
To edit files in place, use -i
option.
sed -i '/STARTING_PATTER/,/^$/d' filename
Or using awk
:
awk 'BEGIN{f=1} /STARTING_PATTERN/{f=0} f{print} !$0{f=1}' filename
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With