0

I want to remove everything after a blank line INCLUDING the blank line. Is there a sed or awk command to do this?

I have a file that looks like:

text
text
moretext
evenmore text


sometexthere
text

I want to remove everything after the first blank line. I want my output to be:

text
text
moretext
evenmore text

I'm not sure how to do this though.

kvantour
  • 25,269
  • 4
  • 47
  • 72
  • Welcome to Stack Overflow. SO is a question and answer page for professional and enthusiastic programmers. Please add your own code to your question. You are expected to show at least the amount of research you have put into solving this question yourself. – Cyrus Jun 03 '20 at 04:59
  • See also [Printing with sed or awk a line following a matching pattern](https://stackoverflow.com/questions/17908555/printing-with-sed-or-awk-a-line-following-a-matching-pattern) – Sundeep Jun 03 '20 at 06:02
  • 1
    Does this answer your question? [remove all lines from a text file starting at first empty line](https://stackoverflow.com/questions/32254011/remove-all-lines-from-a-text-file-starting-at-first-empty-line) – Sundeep Jun 03 '20 at 06:03

1 Answers1

2

You can do this fairly easily with

awk '/^$/{exit}1' ./input/file
SiegeX
  • 135,741
  • 24
  • 144
  • 154