Delete everything after empty line in file

Hello,
I am trying to remove everything coming after empty line under ubuntu14.04.
How may I do it?

file:

aaa
020390
bb00id3
c03wisi

209dl
x092sia
0290s

I expect:

aaa
020390
bb00id3
c03wisi

Thank you
Boris

sed '/^$/q'   filename

Meaning: search for a line containing only begin (^) and end of line ($). Then quit (q).

1 Like

To not print the empty line:

sed -n '/^$/q;p' file
sed '/^$/,$d' file
awk NR==1 RS= file
awk '!NF{exit}1'
1 Like

GNU extension

sed '/^$/Q' file
1 Like