sed print first line before regexp and all lines after

Hi All

I'm trying to extract the line just above a regexp and all lines after this.

I'm currently doing this in two steps

sed -n -e "/^+---/{g;p;}" -e h oldfile.txt > modified.txt
sed -e "1,/^+---/d" -e "/^$/d" oldfile.txt >>modified.txt

Sample

sometext will be here
sometext will be here
sometext will be here
sometext will be here



 ACD                   (A)                   
+------------------------+------------------------
 (some info)                        19082
 (something else)                        19082

Result

 ACD                   (A)                   
 (some info)                        19082
 (something else)                        19082

Is there a way I can achieve this using a one liner?

I'm not sure about sed. Here is a solution using awk:

awk '/^\+/{ print x; getline; f=1; } { x=$0 } f==1 { print $0 }' oldfile.txt
awk '/^\+-/{$0=p; f=1}{p=$0}f' file
1 Like

I tried this one and it works. Thank you