Quantcast
Channel: How to remove multiple lines per occurrence in a file? - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Jander for How to remove multiple lines per occurrence in a file?

$
0
0

The following will work on non-GNU sed (the ,+1 address syntax is a GNU extension):

sed -e '/^a1$/,/^/d' my_file >my_filtered_file

"Starting at a line that reads exactly 'a1', and ending at the next line for which the beginning of the line exists (i.e. the next line), delete."

It's much less extensible than @asoundmove's answer, though, as deleting a different number of lines would take an entirely different script.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>